[Rd] Reading Inf and NaN values under windows (PR#1072)

plummer@iarc.fr plummer@iarc.fr
Fri, 24 Aug 2001 11:56:35 +0200 (MET DST)

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: 

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.


--please do not edit the information below--

 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