[R] using an array of strings with strsplit, issue when including a space in split criteria
Tony Breyal
tony.breyal at googlemail.com
Mon Sep 7 17:40:33 CEST 2009
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
More information about the R-help
mailing list