[R] strsplit

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Oct 22 07:51:49 CEST 2007


On Mon, 22 Oct 2007, Edna Bell wrote:

> Hello R Gurus:
>
> I would like to take a character string and split at the $ sign.
>
> I thought that strsplit would do it, but here are the results:
>
>> vv
> [1] "whine$ts1"
>> vv
> [1] "whine$ts1"
>> strsplit(vv,"$")
> [[1]]
> [1] "whine$ts1"
>
>
> Does anyone have any suggestions, please?

Study the help page?

    split: character vector (or object which can be coerced to such)
           containing regular expression(s) (unless 'fixed = TRUE') to
           use for splitting.

is a big hint to try

> vv <- "whine$ts1"
> strsplit(vv,"$", fixed=TRUE)
[[1]]
[1] "whine" "ts1"

>
> Thanks,
> Edna Bell
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

PLEASE do.


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list