[R] factor question

Henrique Dallazuanna wwwhsd at gmail.com
Thu Jul 24 21:23:02 CEST 2008


Try:

fac1[3:9][drop=T]

On Thu, Jul 24, 2008 at 4:19 PM, Edna Bell <edna.bell01 at gmail.com> 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
>
> Now I want to get rid of the dogs:
>> fac1 <- fac1[3:9]
>> fac1
> [1] cat  cat  cat  tree tree tree tree
> Levels: cat dog tree
>>
> How should I remove the dog from the level, please?
>
> Thanks in advance,
> Edna Bell
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list