data.frame, cbind is inconsistent with S on logicals (PR#316)

About this list Date view Thread view Subject view Author view Other groups

Subject: data.frame, cbind is inconsistent with S on logicals (PR#316)
ripley@stats.ox.ac.uk
Date: Wed 10 Nov 1999 - 20:41:30 EST


Message-Id: <199911101041.LAA18434@pubhealth.ku.dk>

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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Tue 04 Jan 2000 - 14:16:09 EST