[Rd] factors in data.frames (PR#835)

Bill.Venables@CMIS.CSIRO.AU Bill.Venables@CMIS.CSIRO.AU
Fri, 2 Feb 2001 17:30:09 +1000



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