From p.dalgaard@biostat.ku.dk  Fri Mar  9 09:46:15 2001
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 09 Mar 2001 10:46:15 +0100
Subject: [Rd] as.numeric - Possible error (PR#870)
In-Reply-To: maechler@stat.math.ethz.ch's message of "Fri, 9 Mar 2001 10:08:38 +0100 (MET)"
References: <200103090908.KAA16434@pubhealth.ku.dk>
Message-ID: <x2itljl1g8.fsf@blueberry.kubism.ku.dk>

maechler@stat.math.ethz.ch writes:

> >>>>> "harald" == harald fekjar <harald.fekjar@basalmed.uio.no> writes:
> 
>     harald> In R I get:
>     harald> ---
>     >> as.numeric(" ")
>     harald> [1] 0 
...
> 
> Note that it's also for other ``blank like'' strings :
> 
>  > sapply(c("", " ", "\t", "\n", "\r"), as.numeric)
>        \t \n \r 
>   0  0  0  0  0 
> 
> Without having the time currently to investigate your suggested change,
> I tend to agree.

We fixed the same problem in scan() recently. Particularly insidious
since SPSS codes missing with a single blank when exporting delimited
files...

The problem there was that we used strtod which returns 0 for
nonnumerics (what else can it do?) and then checked the rest of the
field with isBlankString - which was true of course. I'll have a look
and see if as.numeric is similar.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] as.numeric - Possible error (PR#870)
Peter Dalgaard BSA