+5 votes
in Programming Languages by (71.8k points)
I want to concatenate small strings to make it a big string. What R function should I use to join or concatenate multiple elements?

1 Answer

+1 vote
by (348k points)
selected by
 
Best answer

Using the paste() function, you can concatenate multiple elements. In the function, comma (,) is used to separate variables, and you can use any number of variables as its parameters. Also, the function puts a space between variables by default, so you do not have to worry about putting a space between variables.

Here is an example:

> a <- "hello"
> b <- "world,"
> c <- "how are you!!"
> paste(a,b,c)
[1] "hello world, how are you!!"


...