Dear All,

it seems to me that levels() deletes other attributes. See the following
example:

## example with levels
f1 <- factor(c('level c','level b','level a','level c'), ordered=TRUE)
attr(f1, 'testattribute') <- 'teststring'
attributes(f1)
levels(f1) <- c('L-A', 'L-B', 'L-C')
attributes(f1)

If I run it, after assigning new levels, the class is only "factor" instead
of "ordered" "factor" and the $testattribute "teststring" is gone.

The same happens to the label() attribute of Hmisc.

## example with levels and label
library(Hmisc)
f1 <- factor(c('level c','level b','level a','level c'), ordered=TRUE)
label(f1) <- 'factor f1'
attr(f1, 'testattribute') <- 'teststring'
attributes(f1)
levels(f1) <- c('L-A', 'L-B', 'L-C')
attributes(f1)

Should I expect this behaviour?

Thanks

Heinz

# R-Version 2.1.0 Patched (2005-05-30)
# Windows98

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to