+4 votes
in Programming Languages by (17.0k 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

0 votes
by (33.7k points)

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!!"

...