Re: [R] Subset doesn't drop unused factor levels

2004-10-07 Thread hadley wickham
Ok. That makes sense. Thanks to you all for your help. Hadley __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Re: [R] Subset doesn't drop unused factor levels

2004-10-07 Thread Frank E Harrell Jr
hadley wickham wrote: a <- data.frame(b = rep(1:5, each=2), c=factor(rep("a",10), levels=c("a","b"))) levels(subset(a, b=1, drop=T)$c) # [1] "a" "b" Is this a bug? Thanks,, Hadley This is always controversial. I am apparently in the small minority in believing that the default behavior is what yo

RE: [R] Subset doesn't drop unused factor levels

2004-10-07 Thread Liaw, Andy
> From: hadley wickham > > a <- data.frame(b = rep(1:5, each=2), c=factor(rep("a",10), > levels=c("a","b"))) > levels(subset(a, b=1, drop=T)$c) > # [1] "a" "b" > > Is this a bug? Don't think so: > args("[.data.frame") function (x, i, j, drop = if (missing(i)) TRUE else length(cols) == 1)

Re: [R] Subset doesn't drop unused factor levels

2004-10-07 Thread Peter Dalgaard
hadley wickham <[EMAIL PROTECTED]> writes: > a <- data.frame(b = rep(1:5, each=2), c=factor(rep("a",10), levels=c("a","b"))) > levels(subset(a, b=1, drop=T)$c) > # [1] "a" "b" > > Is this a bug? In some older versions of R (at least older than 1.9.0), there was a documentation bug in that the he

Re: [R] Subset doesn't drop unused factor levels

2004-10-07 Thread Sundar Dorai-Raj
hadley wickham wrote: a <- data.frame(b = rep(1:5, each=2), c=factor(rep("a",10), levels=c("a","b"))) levels(subset(a, b=1, drop=T)$c) # [1] "a" "b" Is this a bug? Also, I think you meant: levels(subset(a, b==1, drop=T)$c) (Note the double-equals for logical equality) --sundar

Re: [R] Subset doesn't drop unused factor levels

2004-10-07 Thread Sundar Dorai-Raj
hadley wickham wrote: a <- data.frame(b = rep(1:5, each=2), c=factor(rep("a",10), levels=c("a","b"))) levels(subset(a, b=1, drop=T)$c) # [1] "a" "b" Is this a bug? No, drop = TRUE is not doing what you're thinking it's doing. From ?subset (R-1.9.1): The 'drop' argument is passed on to the ind

[R] Subset doesn't drop unused factor levels

2004-10-07 Thread hadley wickham
a <- data.frame(b = rep(1:5, each=2), c=factor(rep("a",10), levels=c("a","b"))) levels(subset(a, b=1, drop=T)$c) # [1] "a" "b" Is this a bug? Thanks,, Hadley __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read