[R] splitting a character vector
John Fox
jfox at mcmaster.ca
Sun Mar 28 19:06:53 CEST 2004
Dear Erin,
unlist(strsplit(xa, " ")) should give you what you want; note that you don't
need c() to define xa in your example.
I hope this helps,
John
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Erin Hodgess
> Sent: Sunday, March 28, 2004 12:03 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] splitting a character vector
>
> 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
>
> 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