Re: [Rd] strsplit ignores empty fields (PR#8271)

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Tue 01 Nov 2005 - 18:05:31 GMT

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@wehi.edu.au <beissbarth@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@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Nov 02 05:19:53 2005

This archive was generated by hypermail 2.1.8 : Tue 01 Nov 2005 - 23:21:25 GMT