Hi Edna,
Because I am "always" subsetting, I keep the following function handy
mydata[] <- lapply(mydata, function(x) if(is.factor(x)) x[,drop=T] else x)
This will strip out all factor levels that have been dropped by a previous
subsetting operation. For novice users of R (though I am not sugge
Try:
fac1[3:9][drop=T]
On Thu, Jul 24, 2008 at 4:19 PM, Edna Bell <[EMAIL PROTECTED]> wrote:
> Hi!
>
> Suppose I have a factor:
>
>> fac1 <- factor(rep(c("dog","cat","tree"),c(2,3,4)))
>> fac1
> [1] dog dog cat cat cat tree tree tree tree
> Levels: cat dog tree
>> length(fac1)
> [1] 9
>
> No
2 matches
Mail list logo