Skip to content

set specific contrasts using lapply

1 message · Rui Barradas

#
Hello,

The value change inside a function's body is lost on exit.
You have changed the value of a copy of the argument passed to the 
function. That copy exists in the function's environment only. And the 
original exists in another environment, the caller's, the parent frame. 
(.GlobalEnv?)
This is valid for contrasts or for any other change you make.
In the case of contrasts, the loop is better, you will always have to 
check wether the object is a factor or logical vector before assigning 
different contrasts levels to it, so you can not use

contrasts(df or list) <- lapply(whatever)

Hope this helps,

Rui Barradas

Em 12-05-2012 11:00, r-help-request at r-project.org escreveu: