[R] splitting a character vector

Uwe Ligges ligges at statistik.uni-dortmund.de
Sun Mar 28 19:07:45 CEST 2004


Erin Hodgess wrote:

> Dear R People:
> 
> Suppose I have the following;
> 
> xa <- c("There are 5 dogs")
> 
> I would like to have a new character vector such that
> xb[1] is There
> xb[2] is are
> xb[3] is 5
> xb[4] is dogs

xb <- unlist(strsplit(xa, " "))

Uwe Ligges



> Since the original vector has length 1, substring will not work.
> 
> Any suggestions would be MOST welcome!
> 
> thanks
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: hodgess at gator.uhd.edu
> 
> R 1.8.1 for Windows
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list