Monday, 27 July 2015

R: paste() : Concatenate strings

“paste” function concatenates vectors by concatenating them term by term. If the argument is not a vector, then simply concatenates.

Usage
paste (..., sep = " ", collapse = NULL)
paste0(..., collapse = NULL)

... : one or more R objects, to be converted to character vectors.
Sep : a character string to separate the terms.
Collapse :  an optional character string to separate the results.

> x<- c("Hello", "How", "are", "you")
> y<- c("I am", "fine")
> 
> paste(x, y)
[1] "Hello I am" "How fine"   "are I am"   "you fine"  
> 
> x<- "Hello"
> y <- "R world"
> 
> paste(x, y)
[1] "Hello R world"


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment