[R] expand.model.frame gives "object not found"

David Hugh-Jones davidhughjones at gmail.com
Thu Sep 30 17:41:52 CEST 2004


Hello,

I am a (relatively) experienced programmer, but new to R.

I have a problem using R 1.9.1. I have fit some data using glm(), from
within a function:

        formula = as.formula(paste(depvarname, "~", rhs), env=globalenv())
        return (glm(formula, family=binomial(link=logit)))

I have now come back to the formula and want to add some more
variables to it. So I do:

expand.model.frame(formulaname, ~ new_variable)

but I get the response

Error in eval(expr, envir, enclos) : Object "foreignaid.dummy" not found

where foreignaid.dummy is my dependent variable. However,
foreignaid.dummy is clearly visible in the global environment:

> ls(pat="foreignaid.dummy", envir=globalenv())
 [1] "foreignaid.dummy"
 ...

So why is my dependent variable lost?

I have read the earlier comments on the same topic, but they seem to
indicate that a previous bug was fixed. Am I missing the point about
scoping?

Any help much appreciated.

David Hugh-Jones
Essex University Govt Dept




More information about the R-help mailing list