From ggrothendieck at gmail.com  Tue Nov  1 19:05:31 2005
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Tue, 1 Nov 2005 13:05:31 -0500
Subject: [Rd] strsplit ignores empty fields (PR#8271)
In-Reply-To: <20051101173604.5D89D23D14@slim.kubism.ku.dk>
References: <20051101173604.5D89D23D14@slim.kubism.ku.dk>
Message-ID: <971536df0511011005j54e968a1x735cc61f3e4893f6@mail.gmail.com>

A workaround would be to append # onto the end of the string:

> s <- c("abc#def", "abc#", "#def")
> ss <- paste(s, "#", sep = "")
> strsplit(ss, "#")
[[1]]
[1] "abc" "def"

[[2]]
[1] "abc" ""

[[3]]
[1] ""    "def"


On 11/1/05, beissbarth at wehi.edu.au <beissbarth at wehi.edu.au> wrote:
> Full_Name: Tim Beissbarth
> Version: 2.2.0
> OS: Windows
> Submission from: (NULL) (193.174.58.254)
>
>
> strsplit ignores empty strings at the end.
>
> > strsplit(paste(c("", "a", ""), collapse="#"), split="#", fixed=TRUE)
> [[1]]
> [1] ""  "a"
>
> This should really give:
> [1] ""  "a"  ""
>
> Some might say this is a feature, but strsplit should be the reverse of paste, I
> think.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] strsplit ignores empty fields (PR#8271)
Gabor Grothendieck