[R] how to write assignment form of function
tuechler at gmx.at
Wed Aug 10 23:25:16 CEST 2005
At 17:44 10.08.2005 +0100, Patrick Burns wrote:
>S Poetry may be of use to you in this.
Thank you for the hint and thank you for S Poetry. I like it, I read it,
maybe about a year ago, but I don't remember all of it and with all the
material I collected about R it's not always easy to remember where I read
>patrick at burns-stat.com
>+44 (0)20 8525 0696
>(home of S Poetry and "A Guide for the Unwilling S User")
>Heinz Tuechler wrote:
>>where can I find information about how to write an assigment form of a
>>For curiosity I tried to write a different form of the levels()-function,
>>since the original method for factor deletes all other attributes of a
>>Of course, the simple method would be to use instead of levels(x) <-
>>newlevels, attr(x, 'levels') <- newlevels.
>>I tried the following:
>>x <- factor(c(1,1,NA,2,3,4,4,4,1,2)); y <- x
>>attr(x, 'levels') <- c('a', 'b', 'c', 'd') # does what I want
>>  a a <NA> b c d d d a b
>>Levels: a b c d
>>'levels.simple<-' <- function (x, value)
>> attr(x, 'levels') <- value
>>levels.simple(y) <- c('a', 'b', 'c', 'd') # does not what I want
>> "a" "b" "c" "d"
>>R-help at stat.math.ethz.ch mailing list
>>PLEASE do read the posting guide!
More information about the R-help