r - how to alternatively concatenate 3 strings -
i have 3 strings:
a<-c("a1","a2","a3") b<-c("b1","b2","b3") c<-c("c1","c2","c3") how can next output:
"a1","b1","c1","a2","b2","c2","a3","b3","c3" here tried:
paste(a,b,c,sep='","') and got:
[1] "a1\",\"b1\",\"c1" "a2\",\"b2\",\"c2" "a3\",\"b3\",\"c3"
is there way it? give thanks you.
you use
c(rbind(a,b,c)) which (rbind) puts 3 variables matrix (row-wise), , (c()) converts them vector, taking advantage of fact r stores matrices in column-wise order.
some of diversity of answers question stems (i think) lack of clarity on op's part (don't know whether issue of understanding or communication ...) between combining individual character strings (e.g. paste("a","b") results in vector of length 1: "a b")) , combining vectors of character strings (c("a","b") results in vector of length 2: "a" "b")
string r concatenation
No comments:
Post a Comment