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

Error in overscope_eval_next(overscope, expr) : object 'G' not found #58

Closed
taqtiqa-mark opened this issue Sep 27, 2017 · 5 comments
Closed

Comments

@taqtiqa-mark
Copy link

taqtiqa-mark commented Sep 27, 2017

Thank you for all your efforts in making these libraries available. Much appreciated!
I believe I have found a minimal(ish) reproducible example of an issue I am also encountering.

library(tidyverse)
library(modelr)

smaller <- diamonds %>% filter(carat < 3)
mod_diamond2 <- lm(price ~ carat + color + cut + clarity, data = smaller)
grid <- smaller %>% 
  data_grid(cut, .model = mod_diamond2) %>% 
  add_predictions(mod_diamond2)
#> Error in eval_tidy(xs[[i]], unique_output): object 'G' not found

Created on 2018-05-10 by the reprex package (v0.2.0).

@pkq

This comment has been minimized.

@fenghaolin

This comment has been minimized.

@hughchipman
Copy link

FWIW, a specific fix to the R for Data Science book is to replace

grid <- diamonds2 %>%
data_grid(cut, .model = mod_diamond2) %>%
add_predictions(mod_diamond2)

with this:

grid <- diamonds2 %>%
data_grid(cut, lcarat = -0.515, color = "G", clarity = "SI1") %>%
add_predictions(mod_diamond2)

Basically explicitly specifying the levels of all factors that are not to be gridded.

@subaiwen

This comment has been minimized.

@hadley
Copy link
Member

hadley commented May 10, 2018

Minimal reprex:

library(modelr)

df <- tibble::tibble(x = rep(c("a", "b"), each = 5), y = rep(c("a", "b"), 5), z = rnorm(10))
mod <- lm(z ~ x + y, data = df)
data_grid(df, .model = mod)
#> Error in eval_tidy(xs[[i]], unique_output): object 'a' not found

Created on 2018-05-10 by the reprex package (v0.2.0).

@hadley hadley closed this as completed in 08b6442 May 10, 2018
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

6 participants