[R] using an array of strings with strsplit, issue when including a space in split criteria

Gabor Grothendieck ggrothendieck at gmail.com
Tue Sep 8 04:30:22 CEST 2009


I am using the exact same version of R as you also on Vista
but can't reproduce your result.  For me it splits properly.

Try starting R like this (modify path if needed) from the
Windows cmd line:

\Program Files\R\R-2.9.2\bin\Rgui --vanilla

and then try it.

On Mon, Sep 7, 2009 at 11:40 AM, Tony Breyal<tony.breyal at googlemail.com> wrote:
> Dear all,
>
> I'm having a problem understanding why a split does not occur with in
> the 2nd use of the function strsplit below:
>
> # text strings
>> txt <- c("sales to 23 August 2008 published 29 August",
> + "sales to 6 September 2008 published 11 September")
>
> # first use
>> strsplit(txt, 'published', fixed=TRUE)
> [[1]]
> [1] "sales to 23 August 2008 " " 29 August"
>
> [[2]]
> [1] "sales to 6 September 2008 " " 11 September"
>
> # second use, but with a space ' ' in the split
>> strsplit(txt, 'published ', fixed=TRUE)
> [[1]]
> [1] "sales to 23 August 2008 " "29 August"
>
> [[2]]
> [1] "sales to 6 September 2008 published 11 September"
>
> Thank you kindly for any help in advance.
> Tony
>
> O/S: Win Vista Ultimate
>> sessionInfo()
> R version 2.9.2 (2009-08-24)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.
> 1252;LC_MONETARY=English_United Kingdom.
> 1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods
> base
>
> other attached packages:
> [1] RODBC_1.3-0
>
> ______________________________________________
> 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.
>




More information about the R-help mailing list