I'm trying to use 'dropterm' (from MASS) in a function along the lines
run <- function(dat){
fit <- (something)(Y ~ (something), data = dat)
lr <- dropterm(fit, test = "Chisq")
return(fit, lr)
}
but running 'run' I get (those scoping rules again...?)
Error in terms.formula(formula, special, data = data) :
Object "dat" not found
This works fine at the command line. Can I send 'dat' to 'dropterm'
somehow, or what should I do?
Thankful for any suggestion, including reading certain books!
G?ran
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
dropterm in a function
4 messages · Göran Broström, Thomas Lumley
On Fri, 4 Oct 2002, [iso-8859-1] Göran Broström wrote:
I'm trying to use 'dropterm' (from MASS) in a function along the lines
run <- function(dat){
fit <- (something)(Y ~ (something), data = dat)
lr <- dropterm(fit, test = "Chisq")
return(fit, lr)
}
but running 'run' I get (those scoping rules again...?)
Error in terms.formula(formula, special, data = data) :
Object "dat" not found
This works fine at the command line. Can I send 'dat' to 'dropterm'
somehow, or what should I do?
What is "something"? If "something" is lm or glm this works for me. I would expect it not to work for lme(). This isn't precisely a scoping rules issue, but a nonstandard evaluation rules one. Functions using model formulas have to do strange things to evaluate variables, and they don't always work consistently. -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 4 Oct 2002, Thomas Lumley wrote:
On Fri, 4 Oct 2002, [iso-8859-1] G?ran Brostr?m wrote:
I'm trying to use 'dropterm' (from MASS) in a function along the lines
run <- function(dat){
fit <- (something)(Y ~ (something), data = dat)
lr <- dropterm(fit, test = "Chisq")
return(fit, lr)
}
but running 'run' I get (those scoping rules again...?)
Error in terms.formula(formula, special, data = data) :
Object "dat" not found
This works fine at the command line. Can I send 'dat' to 'dropterm'
somehow, or what should I do?
What is "something"? If "something" is lm or glm this works for me. I would expect it not to work for lme().
It is 'coxph'. So I shouldn't expect it to work? A pity, because it is a nice feature. Thanks, G?ran -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 4 Oct 2002, [iso-8859-1] Göran Broström wrote:
On Fri, 4 Oct 2002, Thomas Lumley wrote:
On Fri, 4 Oct 2002, [iso-8859-1] Göran Broström wrote:
I'm trying to use 'dropterm' (from MASS) in a function along the lines
run <- function(dat){
fit <- (something)(Y ~ (something), data = dat)
lr <- dropterm(fit, test = "Chisq")
return(fit, lr)
}
but running 'run' I get (those scoping rules again...?)
Error in terms.formula(formula, special, data = data) :
Object "dat" not found
This works fine at the command line. Can I send 'dat' to 'dropterm'
somehow, or what should I do?
What is "something"? If "something" is lm or glm this works for me. I would expect it not to work for lme().
It is 'coxph'. So I shouldn't expect it to work? A pity, because it is a nice feature. Thanks,
No, you should expect it to work, I just know that it doesn't. It needs fixing. -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._