From Richard.Mott at well.ox.ac.uk  Fri Sep 30 11:33:35 2005
From: Richard.Mott at well.ox.ac.uk (Richard.Mott@well.ox.ac.uk)
Date: Fri, 30 Sep 2005 11:33:35 +0200 (CEST)
Subject: [Rd] bug in gsub with perl=TRUE (PR#8164)
Message-ID: <20050930093335.B84DA1C915@slim.kubism.ku.dk>

Full_Name: Richard Mott
Version: 2.0.1
OS: Linux toad 2.6.9 #4 SMP Mon Feb 21 16:20:16 GMT 2005 x86_64 AMD Opteron(tm) Processor 848 AuthenticAMD GNU/Linux
Submission from: (NULL) (129.67.46.247)


gsub with perl=TRUE does not work properly. It pads/truncates the resulting
string to
the length of the input string: 

my.formula <- "log10(Biochem.ALP)^2+1 ~ Family + GENDER"

> gsub("^.+~", "transformed.y ~", my.formula )
[1] "transformed.y ~ Family + GENDER"

> gsub("^.+~", "transformed.y ~", my.formula, perl=TRUE )
[1] "transformed.y ~ Family + GENDER\0\006\0\0\r\377\0\0\0"  # padded

 my.formula <- "Biochem.ALP ~ Family + GENDER"
> gsub("^.+~", "transformed.y ~", my.formula, perl=TRUE )
[1] "transformed.y ~ Family + GEND"  # truncated
> gsub("^.+~", "transformed.y ~", my.formula )
[1] "transformed.y ~ Family + GENDER"



[Rd] bug in gsub with perl=TRUE (PR#8164)
Richard.Mott@well.ox.ac.uk