Was it helpful?

Question

How to concatenate strings in R?

R ProgrammingServer Side ProgrammingProgramming

Concatenation can be done by using paste function in R.

Example

> paste("I", "Love", "R", sep=" ")
[1] "I Love R"

If we want to specify characters between words then it can be done by using collapse argument as follows −

> x <- c("I", "Love", "R")
> x
[1] "I" "Love" "R"
> paste(x, collapse="-")
[1] "I-Love-R"
raja
Published on 06-Jul-2020 16:30:04
Advertisements
Was it helpful?
Not affiliated with Tutorialspoint
scroll top