[Rd] grep, gsub, sub have problems with NA values (PR#3078)

Warnes, Gregory R gregory_r_warnes at groton.pfizer.com
Sat May 24 09:17:22 MEST 2003


I see that this came out garbled.  It should have read:

FormatC also has problems:  It incorrectly convertys any factor level
*containing* the characters 'NA' to a missing value.

> > formatC(factor("NAME"),width=8)
> [1] <NA>
> Levels: NAME

-G


> -----Original Message-----
> From: Warnes, Gregory R 
> Sent: Friday, May 23, 2003 5:22 PM
> To: 'Thomas Lumley'; Warnes, Gregory R
> Cc: r-devel at stat.math.ethz.ch
> Subject: RE: [Rd] grep, gsub, sub have problems with NA 
> values (PR#3078)
> 
> 
> 
> FormatC also has the reverse problem, it detects any factor 
> contianing the string "NA" and converts it to a factor:
> 
> > formatC(factor("NAME"),width=8)
> [1] <NA>
> Levels: NAME
> 
> -Greg
> 
> 
> 
> > -----Original Message-----
> > From: Thomas Lumley [mailto:tlumley at u.washington.edu]
> > Sent: Friday, May 23, 2003 11:47 AM
> > To: gregory_r_warnes at groton.pfizer.com
> > Cc: r-devel at stat.math.ethz.ch
> > Subject: Re: [Rd] grep, gsub, sub have problems with NA 
> > values (PR#3078)
> > 
> > 
> > On Thu, 22 May 2003 gregory_r_warnes at groton.pfizer.com wrote:
> > 
> > >
> > > In a string context, grep, gsub, sub are improperly 
> > treating NA (missing) as
> > > the string "NA", and returning unexpected results
> > >
> > 
> > as were chartr, abbreviate, substr, substring, strsplit. 
> > Fixed in r-devel,
> > for the case of NA in the `main' string. Haven't yet decided 
> > what to do
> > about
> >   grep(as.character(NA), x)
> > or
> >   substr(x,1,2)<-as.charcter(NA)
> > 
> > 
> > 
> > 	-thomas
> > 
> 


LEGAL NOTICE\ Unless expressly stated otherwise, this message is... {{dropped}}



More information about the R-devel mailing list