Question: R programming, concatenate or combine all the column contents
4
MAPK • 1.7k wrote:
Hi Guys,
I want to concatenate all these values in the columns enclosed with "" and separated by comma in the order as shown below. How can I get this done in R?
df1
chr | start | end | strand |
chr4 | 443333 | 232444 | + |
chr5 | 4455332 | 4433323 | - |
chr5 | 4443333 | 4433355 | + |
I want this result
Result (exactly as shown below):
"chr4","443333","232444","+","chr5","4455332","4433323","-","chr5","4443333","4433355","+"
Tried this, but didn't get what I want.
all<-paste(mydf[,"chr"],mydf[,"start"],mydf[,"end"],mydf[,"strand"], sep=",")
allkeys <- cat(paste(shQuote(all, type="cmd"), collapse=", "))