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

emmeans() and mutate() in "visualizing_uncertainty.Rmd" (lines 398 ff.) #108

Open
napaxton opened this issue Oct 8, 2020 · 1 comment
Open

Comments

@napaxton
Copy link

napaxton commented Oct 8, 2020

Not sure this is actually an "issue."

Trying to replicate one of your graphs (16.5-Cocoa data v. CI), and I am running into a problem with emmeans and mutate. Here's the code in question:

cacao %>% 
  filter(location == "Canada") -> cacao_single

fit <- lm(rating ~ 1, data = cacao_single)

CI_df <- data.frame(type = c(0.8, 0.95, 0.99)) %>%
  mutate(df = map(type, ~tidy(emmeans(fit, ~ 1, options = list(level = .x))))) %>%
  unnest() %>%
  select(type, estimate, std.error, conf.low, conf.high) %>%
  mutate(type = paste0(signif(100*type, 2), "% confidence interval"))

When I run this code, I get the error Error: Can't subset columns that don't exist. x Column conf.low doesn't exist.

I've played around with the first mutate statement, and it seems that the emmeans estimation created there does not seem to iterate over creating the high and low CIs. While the emmeans statement used iteratively does produce the CIs as part of the output, within the mutate, the CIs don't get created.

At first I thought this was a mutate issue (as seen at https://stackoverflow.com/questions/64265476/problems-mutate-ing-and-select-ing-over-a-list-of-tibbles/), but it seems more to be emmeans.

Again, apologies if this isn't quite an issue, but wasn't sure where to turn on this, and the source seemed best.

@cameronj86
Copy link

Experiencing the same issue 🤔

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