Hi Gianni, Thank you for the reproducible example!
Try mydf$newID <- with(mydf, gsub("_", "Sample", ID)) mydf HTH, Jorge.- On Fri, Mar 16, 2012 at 7:54 AM, gianni lavaredo <> wrote: > Dear Researchers, > > I have a data.frame with 2 columns like this: > > mydf <- > > data.frame(value=c(1,2,3,4,5),ID=c("Area_1","Area_2","Area_3","Area_4","Area_5")) > > > mydf > value ID > 1 1 Area_1 > 2 2 Area_2 > 3 3 Area_3 > 4 4 Area_4 > 5 5 Area_5 > > > I need to convert the *ID *in the following version > > mydf > value ID newID > 1 1 Area_1 AreaSample1 > 2 2 Area_2 AreaSample2 > 3 3 Area_3 AreaSample3 > 4 4 Area_4 AreaSample4 > 5 5 Area_5 AreaSample5 > > some people know the right function to split ID and create a new column > > Thanks in advance > Gianni > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.