tommy chheng
tommy chheng

Reputation: 9228

How do concat a vector of character in R?

I tried using the paste command but it returns the same vector?

x = c("a","b","c")
y = paste(x)
y
[1] "a" "b" "c"
length(y)
[1] 3

I want a single character of "abc"

Upvotes: 4

Views: 528

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368609

The collapse="" options is your friend:

> x <- c("a", "b", "c")
> paste(x, collapse="")
[1] "abc"
> 

[ There is still no rstats tag here. ]

Upvotes: 7

Related Questions