Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formula environment causing error #34

Closed
ngreifer opened this issue Jun 8, 2018 · 2 comments
Closed

Formula environment causing error #34

ngreifer opened this issue Jun 8, 2018 · 2 comments

Comments

@ngreifer
Copy link
Contributor

ngreifer commented Jun 8, 2018

See this example:

X <- rnorm(100)
Y <- rnorm(100)
F <- function(f) summ(glm(f))
F(Y ~ X)

## Error: object of type 'symbol' is not subsettable 

The traceback is:

10. notnull(x$formula) 
9. formula.default(object, env = baseenv()) 
8. formula(object, env = baseenv()) 
7. as.formula(old) 
6. update.formula(call$formula, formula) 
5. j_update(object, formula = form, weights = .weights, offset = .offset, 
    data = frame) 
4. pR2(model) 
3. summ.glm(glm(f)) 
2. summ(glm(f)) 
1. F(Y ~ X) 

I think this is occurring because the environment in which you are evaluating the formula when decomposing the glm object is not the same environment with the data. Note that this occurs even when a data set is included in glm. This isn't a huge problem but points to a possible underlying issue. The way around it is to pass the glm object to F() rather than just the formula.

@jacob-long
Copy link
Owner

Programmatic model updating is a bear. I think I've fixed it.

@ngreifer
Copy link
Contributor Author

Yup! Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants