[R] Q about strsplit and regexp
ggrothendieck at myway.com
Thu Oct 21 07:45:42 CEST 2004
Liaw, Andy <andy_liaw <at> merck.com> writes:
: > I do not want that empty character in the beginning, but
: > couldn't figure out
: > how to strip the starting white spaces, other than something
: > ugly like:
: > > strsplit(sub("^ +", "", " a b c "), " +")
: > []
: >  "a" "b" "c"
: Looks like there's no easier way than to strip the spaces before
: splitting the fields.
Here is a way to split it up without first stripping away leading spaces:
scan(textConnection(" a b c "), what = "")
More information about the R-help