Dear All,
to drop unused factor levels two ways are outlined in R-help. In both
cases a label attribute is lost.
The same happens, when using car:::recode.
Is there a simple way to avoid losing attributes?
Thanks,
Heinz
## example
ff <- factor(substring("statistics", 1:10, 1:10), levels=letters)
attributes(ff)$label <- 'test label'
attributes(ff)$label
gg <- ff[, drop=TRUE]
attributes(gg)$label
hh <- factor(ff)
attributes(hh)$label
ii <- car:::recode(ff, "'t'='s'")
attributes(ii)$label
> version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status Patched
major 2
minor 8.1
year 2009
month 03
day 13
svn rev 48132
language R
version.string R version 2.8.1 Patched (2009-03-13 r48132)
> sessionInfo()
R version 2.8.1 Patched (2009-03-13 r48132)
i386-pc-mingw32
locale:
LC_COLLATE=German_Austria.1252;LC_CTYPE=German_Austria.1252;LC_MONETARY=German_Austria.1252;LC_NUMERIC=C;LC_TIME=German_Austria.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] car_1.2-12
______________________________________________
R-help@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.