The following seems to be a contradiction:> df <- data.frame(x=gl(2,1,10)) > df[,1][1] 1 2 1 2 1 2 1 2 1 2 Levels: 1 2> df[,1,drop=F]x 1 1 2 2 3 1 4 2 5 1 6 2 7 1 8 2 9 1 10 2> is.factor(df[,1,drop=F])[1] FALSE> is.factor(df[,1])[1] TRUE with R1.2.1 both MS Windows and Intel RH5.2 versions. Jim -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> From: james.lindsey@luc.ac.be > Date: Thu, 1 Feb 2001 10:56:07 +0100 (MET) > > The following seems to be a contradiction:What is, pray?> class(df[, 1])[1] "factor"> class(df[, 1, drop = FALSE])[1] "data.frame" df[ , 1, drop=FALSE] is a data frame, so not a factor. df[ , 1] is a factor.> > df <- data.frame(x=gl(2,1,10)) > > df[,1] > [1] 1 2 1 2 1 2 1 2 1 2 > Levels: 1 2 > > df[,1,drop=F] > x > 1 1 > 2 2 > 3 1 > 4 2 > 5 1 > 6 2 > 7 1 > 8 2 > 9 1 > 10 2 > > is.factor(df[,1,drop=F]) > [1] FALSE > > is.factor(df[,1]) > [1] TRUE > > with R1.2.1 both MS Windows and Intel RH5.2 versions. > Jim-- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
| -----Original Message----- | From: james.lindsey@luc.ac.be [mailto:james.lindsey@luc.ac.be] | Sent: Thursday, 1 February 2001 19:56 | To: r-devel@stat.math.ethz.ch | Cc: R-bugs@biostat.ku.dk | Subject: [Rd] factors in data.frames (PR#835) | | | The following seems to be a contradiction: | | > df <- data.frame(x=gl(2,1,10)) | > df[,1] | [1] 1 2 1 2 1 2 1 2 1 2 | Levels: 1 2 | > df[,1,drop=F] | x | 1 1 | 2 2 | 3 1 | 4 2 | 5 1 | 6 2 | 7 1 | 8 2 | 9 1 | 10 2 | > is.factor(df[,1,drop=F]) | [1] FALSE | > is.factor(df[,1]) | [1] TRUE | | with R1.2.1 both MS Windows and Intel RH5.2 versions. | Jim Eh? df[,1,drop = F] is a data frame with one component and hence NOT a factor but df[,1] is one (factor) component of a fata frame and hence IS a factor. I think it is entirely consistent with the advertised behaviour. Bill. | -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._