data.frame, cbind is inconsistent with S on logicals (PR#316)
ripley@stats.ox.ac.uk
ripley@stats.ox.ac.uk
Wed, 10 Nov 1999 11:41:30 +0100 (MET)
R 0.65.1 (and R-devel 09/11/99)
> z <- data.frame(a=1:3)
> b <- rep(NA, 3)
> mode(b)
[1] "logical"
# how many of you expected that? I had forgotten!
> zz <- cbind(z, b)
> zz
a b
1 1 NA
2 2 NA
3 3 NA
> class(zz$b)
[1] "factor"
whereas in S it is NULL and zz$b is of mode "numeric".
The same thing happens with data.frame
zz <- data.frame(a, b)
gives zz$b as a factor in R and numeric in S.
I don't think this is a desirable difference, at least with all NAs!
--
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._