plummer@iarc.fr
2001-Aug-24 09:56 UTC
[Rd] Reading Inf and NaN values under windows (PR#1072)
Under windows, R supports IEEE floating point arithmetic, but doesn't allow conversion of Inf and NaN from character to numeric. R> is.nan(NaN) [1] TRUE R> as.numeric(as.character(NaN)) [1] NA Warning message: NAs introduced by coercion R> is.infinite(Inf) [1] TRUE R> as.numeric(as.character(Inf)) [1] NA Warning message: NAs introduced by coercion whereas under Linux R> as.numeric(as.character(NaN)) [1] NaN R> as.numeric(as.character(Inf)) [1] Inf S-PLUS 3.3 for Windows gives S-PLUS> as.numeric(as.character(Inf)) [1] Inf S-PLUS> as.numeric(as.character(NaN)) [1] NA Warning messages: 1 missing value generated coercing from character to numeric in: as.numeric(as.character(NaN)) I first came across this problem when trying to read in a dataset with Inf values using read.table(). Under Windows, the variable with the infinite value is converted to a factor. The scan() function also refuses to read in Inf and NaN as numeric values under Windows. Martyn --please do not edit the information below-- Version: platform = i386-pc-mingw32 arch = x86 os = Win32 system = x86, Win32 status = major = 1 minor = 3.0 year = 2001 month = 06 day = 22 language = R Windows NT 4.0 (build 1381) Service Pack 6 Search Path: .GlobalEnv, package:ctest, Autoloads, package:base -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Prof Brian Ripley
2001-Aug-24 14:23 UTC
[Rd] Reading Inf and NaN values under windows (PR#1072)
On Fri, 24 Aug 2001 plummer@iarc.fr wrote:> Under windows, R supports IEEE floating point arithmetic, but doesn't > allow conversion of Inf and NaN from character to numeric. > > R> is.nan(NaN) > [1] TRUE > R> as.numeric(as.character(NaN)) > [1] NA > Warning message: > NAs introduced by coercion > R> is.infinite(Inf) > [1] TRUE > R> as.numeric(as.character(Inf)) > [1] NA > Warning message: > NAs introduced by coercion > > whereas under Linux > > R> as.numeric(as.character(NaN)) > [1] NaN > R> as.numeric(as.character(Inf)) > [1] Inf > > S-PLUS 3.3 for Windows gives > > S-PLUS> as.numeric(as.character(Inf)) > [1] Inf > S-PLUS> as.numeric(as.character(NaN)) > [1] NA > Warning messages: > 1 missing value generated coercing from character to numeric in: > as.numeric(as.character(NaN)) > > I first came across this problem when trying to read in a dataset with > Inf values using read.table(). Under Windows, the variable with the > infinite value is converted to a factor. The scan() function also refuses > to read in Inf and NaN as numeric values under Windows.It's the same cause: strtod is used. That's not required to support IEC 60559 (to be correct) specials, but glibc happens to. We have R_strtod: we should make proper use of it. I'll do that for 1.3.1. Brian> > Martyn > > --please do not edit the information below-- > > Version: > platform = i386-pc-mingw32 > arch = x86 > os = Win32 > system = x86, Win32 > status > major = 1 > minor = 3.0 > year = 2001 > month = 06 > day = 22 > language = R > > Windows NT 4.0 (build 1381) Service Pack 6 > > Search Path: > .GlobalEnv, package:ctest, Autoloads, package:base > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._