[R] coercing NA to complex?
John Peters
John.Peters at tip.csiro.au
Mon May 8 02:22:11 CEST 2000
I struck a problem concatenating two complex vectors with an NA for
plotting purposes. It seems that NA is not automatically coerced to mode
complex. In the complex vector "b" below, an NA appears after half the
vector, and a zero appears where the NA should be:
3+4i 3+4i NA 3+4i 0+0i 3+4i 3+4i 3+4i 3+4i 285
This zero seems to coming from free space, as, after running this example
a few times, the zero gets replaced by some sort of erratic garbage:
3+4i 3+4i NA 3+4i 2.466318e+179+6.800902e+199i 3+4i 3+4i 3+4i 3+4i 292
Is this a misuse of c() and NA or a bug? It runs OK in Splus 3.4.
Observed on R 1.0.1 on both linux (compiled on RedHat 6.2) and win95
(rw1001).
#---------------------------------------------------------------------
a_rep(3+4i,4)
for (i in 1:1000){
b_c(a,NA,a) # b is wrong
# b_c(a,as.complex(NA),a) # b is ok
cat(b,i,"\n")
x_max(c(1,Mod(b[5])),na.rm=T)
if (x>2) stop()
}
#---------------------------------------------------------------------
Thanks for R; this is my first surprise for many months.
----------------------------------------------------------------------------
John Peters
CSIRO National Measurement Laboratory
PO Box 218 Phone: +61 2 9413 7503
Lindfield NSW 2070 Fax: +61 2 9413 7202
Australia Internet: John.Peters at tip.CSIRO.AU
----------------------------------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list