[R] How to replace all commas with semicolon in a string

Mohammad Goodarzi mohammad.godarzi at gmail.com
Tue May 31 14:55:30 CEST 2016


here is the solution to your question

test <- data.frame(C1=c('a,b,c,d'),C2=c('g,h,f'))

you should use gsub instead sub if you want it to be on all elements of
each column

tFun <- function(x) {gsub(",",";",x)}
newTest <- apply(test, 2, tFun )

Cheers,

	[[alternative HTML version deleted]]



More information about the R-help mailing list