Lefebure Tristan <[EMAIL PROTECTED]> writes:
> Hi,
> Just something I don't understand:
>
> data <- data.frame(V1=c(1:12),F1=c(rep("a",4),rep("b",4),rep("c",4)))
> data_ac <- data[which(data$F1 !="b"), ]
> levels(data_ac$F1)
>
> Why the level "b" is always present ?
Because it is a property of the definition, not of the data. E.g. if
you tabulate it, you generally want to get a zero entry if there are
no "b"s in the data. If, for some reason, you want to reduce the
factor to only those levels that are present, factor() gets you there
soon enough:
> levels(factor(data_ac$F1))
[1] "a" "c"
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907
______________________________________________
[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