Skip to content
Prev 200308 / 398503 Next

update.lm question

On 15/11/2009 9:23 AM, Karsten Weinert wrote:
There are two problems:

1. ".~." is different from ". ~ .".

2.  You need to construct the formula ". ~ . - x1", and none of your 
expressions do that.  You need to use substitute() or bquote() to edit a 
formula. For example, I think both of these should work:

removeTerm <- function(linModel, termName)
    update(linModel, bquote(. ~ . - .(as.name(termName))))


removeTerm <- function(linModel, termName)
    update(linModel, substitute(. ~ . - x, list(x=as.name(termName))))

Duncan Murdoch