jens.oehlschlaegel-akiyoshi@mdfactory.de
2000-Jan-04 09:37 UTC
formatC (bug and fix) (PR#394)
OK:> formatC(as.double(c(1,0,NA)))[1] "1" "0" "NA" NOT OK:> formatC(as.integer(c(1,0,NA)))[1] "0" "1072693248" "NA"> formatC(as.integer(c(0,1,NA)))[1] "0" "0" "NA" BUG TRACED TO R-code of formatC() where x[!Ok] <- 0 unintendedly changes the storage.mode of x to double, while variable mode still signifies 'integer'. Thus the following is probably ok as bug fix ProperZero <- 0 storage.mode(ProperZero) <- mode x[!Ok] <- ProperZero At least the following tests are positive using this fix> formatC(as.integer(c(1,0,NA)))[1] "1" "0" "NA"> formatC(as.double(c(1,0,NA)))[1] "1" "0" "NA"> > formatC(as.integer(c(1,0,NA)), format="d")[1] "1" "0" "NA"> formatC(as.double(c(1,0,NA)), format="d")[1] "1" "0" "NA"> formatC(as.integer(c(1,0,NA)), format="f")[1] "1.0000" "0.0000" "NA"> formatC(as.double(c(1,0,NA)), format="f")[1] "1.0000" "0.0000" "NA"> > formatC(as.integer(c(1,0,NA)), mode="integer")[1] "1" "0" "NA"> formatC(as.double(c(1,0,NA)), mode="integer")[1] "1" "0" "NA"> formatC(as.integer(c(1,0,NA)), mode="double")[1] "1" "0" "NA"> formatC(as.double(c(1,0,NA)), mode="double")[1] "1" "0" "NA"> > formatC(as.integer(c(1,0,NA)), mode="integer", format="d")[1] "1" "0" "NA"> formatC(as.double(c(1,0,NA)), mode="integer", format="d")[1] "1" "0" "NA"> formatC(as.integer(c(1,0,NA)), mode="double", format="d")[1] "1" "0" "NA"> formatC(as.double(c(1,0,NA)), mode="double", format="d")[1] "1" "0" "NA"> > formatC(as.integer(c(1,0,NA)), mode="integer", format="f")[1] "1.0000" "0.0000" "NA"> formatC(as.double(c(1,0,NA)), mode="integer", format="f")[1] "1.0000" "0.0000" "NA"> formatC(as.integer(c(1,0,NA)), mode="double", format="f")[1] "1.0000" "0.0000" "NA"> formatC(as.double(c(1,0,NA)), mode="double", format="f")[1] "1.0000" "0.0000" "NA"> version_ platform Windows arch x86 os Win32 system x86, Win32 status major 0 minor 90.1 year 1999 month December day 15 language R Best regards -- Dr. Jens Oehlschlägel-Akiyoshi MD FACTORY GmbH Bayerstrasse 21 80335 München Tel.: 089 545 28-27 Fax.: 089 545 28-10 http://www.mdfactory.de Standard Disclaimers: Opinions expressed here are personal and are not otherwise represented. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._