[R] string manip

Emmanuel Paradis paradis at isem.univ-montp2.fr
Fri Sep 6 16:25:15 CEST 2002


At 16:18 06/09/02 +0200, you wrote:
>Hello,
>
>I need to split a string in elements but I cannot find how to.
>
>I have a string:     s<-"Block Column ID"      for example
>I would like to obtain a vector with 3 elements
>
>Is there a function to do this?

Yes, the function strsplit returns a list, so in your example:

> s <- "Block Column ID"
> unlist(strsplit(s, " "))
[1] "Block"  "Column" "ID"


EP

>Vincent
>
>-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
.-.-
>r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
>Send "info", "help", or "[un]subscribe"
>(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
>_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
._._
>
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list