-
Notifications
You must be signed in to change notification settings - Fork 740
Description
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.