user3762482
user3762482

Reputation:

Paste-Collapse numbers in R

I have three variables:

s num [1:4] 8 1 8 6
q num [1:4] 1 2 3 3
c num [1:4] 3 3 3 3

I want to concatenate and collapse the variables, so I do this:

num <- (paste(s,q,c,sep = "", collapse=" "))

And the result is that I want:

num [1] "813 123 833 633"

But my problem now is that the result is no longer numeric and I want them separated and numeric, how could I do that? Thanks in advance

Upvotes: 0

Views: 2791

Answers (1)

Karsten W.
Karsten W.

Reputation: 18440

How about

as.numeric(paste(s,q,c,sep=""))

?

Upvotes: 4

Related Questions