[Rd] sub returns garbage (PR#8687)
mschwartz@mn.rr.com
mschwartz at mn.rr.com
Thu Mar 16 22:43:57 CET 2006
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
More information about the R-devel
mailing list