[R] strsplit behavior
Thomas Lumley
tlumley at u.washington.edu
Mon Dec 17 18:59:26 CET 2001
On Mon, 17 Dec 2001, Niels Waller wrote:
> I am trying (with no success) to split a string at a period. Should I be
> using a different function?
<snip>
> > strsplit(x,".")
> [[1]]
> [1] "" "" "" "" "" "" ""
No, the problem is that the split argument is a regular expression, not a
character string. "." is a regular expression that matches any single
character.
You want strsplit(x,"\\."), a regular expression that matches only the "."
character. This *is* one of the examples in help(strsplit)
-thomas
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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