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
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
> 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)
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
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
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
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