I'm trying convert this vector string
a<-c("1,2,3","344")
into this
a<-c("1","2","3","344")
I'm using the following code:
a<-c("1,2,3","344")
b<-strsplit(a, ",")
c<-sapply( b, paste0, collapse=",")
But I'm getting back to the original vector:
c<-c("1,2,3","344")
Any help would be appreciated.
Thanks,
Albit
Try:
a <- c("1,2,3","344")
scan(text = a, sep = ",", what = "")
# [1] "1" "2" "3" "344"
This solution is identical to the one on my comment:
a <- c("1,2,3", "344")
b <- unlist(strsplit(a, ","))
b
[1] "1" "2" "3" "344"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With