[R] applying strsplit to a whole column

Erik Iverson eriki at ccbr.umn.edu
Wed Aug 4 19:55:34 CEST 2010

Dimitri Liakhovitski wrote:
> I am sorry, I'd like to split my column ("names") such that all the
> beginning of a string ("X..") is gone and only the rest of the text is
> left.
> x<-data.frame(names=c("X..aba","X..abb","X..abc","X..abd"))
> x$names<-as.character(x$names)
> (x)
> str(x)
> Can't figure out how to apply strsplit in this situation - without
> using a loop. I hope it's possible to do it without a loop - is it?

If I understand, strsplit isn't necessary:

sub("X\\.+", "", x$names)

More information about the R-help mailing list