From thomas@biostat.washington.edu  Tue Feb  8 16:26:14 2000
From: thomas@biostat.washington.edu (Thomas Lumley)
Date: Tue, 8 Feb 2000 16:26:14 +0000 (GMT)
Subject: [Rd] strsplit (PR#424)
In-Reply-To: <200002081158.MAA19367@pubhealth.ku.dk>
Message-ID: <Pine.LNX.4.10.10002081620410.7440-100000@gimel.biostat.washington.edu>

On Tue, 8 Feb 2000 jlindsey@alpha.luc.ac.be wrote:

> In R.99, when you strsplit with a space (split=" ") as separator and
> the string contains two consecutive spaces, "" is returned.
> 
> strsplit("  "," ")
> returns
> [[1]]
> [1] "" ""
> whereas it used to return character(0)
>   Is this really useful like this?? It certainly messes all my code up. Jim

It is useful like that. It messed up some other people's code, too (eg
mine), but with the previous behaviour there was no way to distinguish
single and double separators. You can now do

	a<-strsplit(vector.of.strings," ")
	b<-lapply(a,function(x) x[x!=""])

to get the old behaviour (and lapply() is now internal C code).

	-thomas


Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] strsplit (PR#424)
Thomas Lumley