I have a data frame mynames of a single column that i wish to convert to a character string. The aim being to select the names of columns in another dataset based on the items in this string. An example of the data is below
X
A
B
C
I tried using the code below to paste it all together using the following code
paste(mynames, sep="", collapse="")
However that produces the out put below which is far from ideal
"c(\"A\", \"B\", \"C\",..........
Can anyone help?
Try
dat <- data.frame(x=c("a","b","c"))
st <- paste(dat$x,collapse="")
st
prints
> st
[1] "abc"
and to make it comma-separated:
> st <- paste(dat$x,collapse=",")
> st
[1] "a,b,c"
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