From mschwartz at mn.rr.com  Thu Mar 16 22:43:57 2006
From: mschwartz at mn.rr.com (mschwartz@mn.rr.com)
Date: Thu, 16 Mar 2006 22:43:57 +0100 (CET)
Subject: [Rd] sub returns garbage (PR#8687)
Message-ID: <20060316214357.EACFB103EE@slim.kubism.ku.dk>

On Thu, 2006-03-16 at 22:28 +0100, todd at baileywick.plus.com wrote:
> Full_Name: Todd Bailey
> Version: 2.1
> OS: Mac OS-X 10.4.3
> Submission from: (NULL) (87.112.79.124)
> 
> 
> sub returns garbage in some strings when replacing something with nothing and
> fixed=TRUE.  For example:
> 
> > a=c('hello','hello'); sub('lo','',a,fixed=TRUE)
> [1] "hel"     "hel\0\0"
> > a=c('hello','hello'); sub('lo','',a,fixed=FALSE)
> [1] "hel" "hel"


This has been fixed in R Patched. From NEWS:

 o	sub(fixed = TRUE) could get wrong the length of the character
	string of elements of the result after the first.


>From my installation:

> a <- c('hello', 'hello'); sub('lo', '', a, fixed=TRUE)
[1] "hel" "hel"

> a <- c('hello', 'hello'); sub('lo', '', a, fixed=FALSE)
[1] "hel" "hel"


HTH,

Marc Schwartz



[Rd] sub returns garbage (PR#8687)
mschwartz@mn.rr.com