I'm using a past mentor's code that previously worked but I can't figure out what to do about this error. I'm using fish density to look at the effects of treatment of restored side channels on fish.
#Here is a model
BACI_salmonid_acre_T <- glmmTMB(salmonid_acre ~ season + before_after*treatment_1 + (1 | pair), data = BACI1, ziformula = ~0, family = tweedie)
#Here are the emmeans and graph following AFS guidelines
em_baci <- emmeans(BACI_salmonid_acre_T, ~ before_after | treatment_1, type = "response")
df_baci <- as.data.frame(em_baci)
df_baci <- df_baci %>%
mutate(Treatment = treatment_1,
before_after = factor(before_after, levels = rev(levels(df_baci$before_after))))
S_acre <- ggplot(df_baci, aes(before_after, response,
color = Treatment, shape = Treatment, group = Treatment)) +
geom_line(position = position_dodge(width = 0.1)) +
geom_linerange(aes(ymin = asymp.LCL, ymax = asymp.UCL),
position = position_dodge(width=0.1)) +
geom_point(position = position_dodge(width = 0.1), size=2) +
labs(x = "Restoration timeline", y = "Fish-per-acre (EMM)", title=" ") +
theme_bw() +
theme(panel.grid.minor = element_blank(), panel.grid.major.x = element_blank(), panel.grid.major.y = element_line(linewidth = 0.2) ) +
theme(text=element_text(family="Times New Roman", size=8)) +
scale_color_manual(values=c("grey65", "black")) +
theme(panel.border = element_blank(), axis.line = element_line()) +
theme(legend.position=c(0.9,0.9)) +
ylim(0,425)+
annotation_custom(grob)
#Here is where I output a single graph, although this will eventually go into a panel
setwd("D:/R code B13 Mandy's Notes/B13 project code and data files for Greyson/BACI counts and density models (from Manuscript and 2021-22 Annual Report)/figs")
ggsave(file="Salmonid Density - Single Panel.tiff", width=4.125, height=2.75, dpi=300)
I tried rlang's last_trace() function but couldn't pinpoint where the problem is. I also tried downloading a few different packages hoping that would help but was unsuccessful.