Subject: Re: data.frame, cbind is inconsistent with S on logicals (PR#316)
Date: Wed 10 Nov 1999 - 21:59:43 EST
> From: Peter Dalgaard BSA <email@example.com>
> Date: 10 Nov 1999 12:14:33 +0100
> firstname.lastname@example.org writes:
> > R 0.65.1 (and R-devel 09/11/99)
> > > z <- data.frame(a=1:3)
> > > b <- rep(NA, 3)
> > > mode(b)
> >  "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)
> >  "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!
> Hmmm. Notice that in *both* R and S3,
> > class(data.frame(x=TRUE)$x)
>  "factor"
> And in both dialects, NA is a logical constant. So S3 is doing a
> special exception for all-NA logical vectors. Of course, we could just
> clone that...
It isn't: I was using the S4-style data frame code in my copy of
S-PLUS 3.4 (it is needed for some recent extensions) and had not
noticed. And S4 keeps these logical, which seems much more desirable
to me. In both R and S it is a quirk that
z$b <- b
z <- cbind(z, b)
are different, but not in S4 nor in S3+library(df)
I withdraw this.
-- Brian D. Ripley, email@example.com 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: firstname.lastname@example.org _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2b25 : Tue 04 Jan 2000 - 14:16:09 EST