So I just got a fantastic answer to a question in another thread and that answer revealed another problem.
I'm trying to create a graph of some leaf sizes, and this code works:
Mass.dat <- read_excel("CoSAR Final.xlsx", sheet = "ImageJ", na="NA") %>%
mutate(Treatment = as.factor(Treatment),
Whorl = as.factor(Whorl))
Mass.mean<-summarySE(Mass.dat,measurevar = "Leaf.Mass",
groupvars = c("Whorl","Treatment"),
na.rm = T)
LeafMassWhorl<-ggplot(data=subset(Mass.mean, !is.na(Leaf.Mass)),
aes(y=Whorl, x=Leaf.Mass, color=Treatment))+
geom_errorbar(aes(xmin=Leaf.Mass-se,xmax=Leaf.Mass+se),size=0.5,width=1.5)+
geom_point(size=3,
aes(color = Treatment))+
theme_minimal_hgrid()+
facet_wrap( ~Treatment, scales = "fixed")+ theme(legend.title=element_blank())+
labs(y="Whorl", x="Leaf Biomass (mg)")+
theme(legend.direction="horizontal", legend.position = "top")
LeafMassWhorl
...but with this one, I get the 'object SE not found' error:
Mass.dat <- read_excel("CoSAR Final.xlsx", sheet = "ImageJ", na="NA") %>%
mutate(Treatment = as.factor(Treatment),
Whorl = as.factor(Whorl))
Mass.mean2<-Mass.dat %>%
group_by(Treatment) %>%
dplyr::summarize(Leaf.Mass = mean(Leaf.Mass, na.rm=TRUE))
LeafMassTrt<-ggplot(data=subset(Mass.mean2, !is.na(Leaf.Mass)),
aes(y=Treatment, x=Leaf.Mass, color=Treatment))+
geom_errorbar(aes(xmin=Leaf.Mass-se,xmax=Leaf.Mass+se),size=0.5,width=1.5)+
geom_point(size=3,
aes(color = Treatment))+
theme_minimal_hgrid()+
labs(y="Treatment", x="Leaf Biomass (mg)")+
theme(legend.direction="horizontal", legend.position = "top")
LeafMassTrt
Here's the error traceback for the code above:
Error in FUN(X[[i]], ...) : object 'se' not found
11.
FUN(X[[i]], ...)
10.
lapply(aesthetics[new_aesthetics], eval_tidy, data = data)
9.
scales_add_defaults(plot$scales, data, aesthetics, plot$plot_env)
8.
f(..., self = self)
7.
l$compute_aesthetics(d, plot)
6.
f(l = layers[[i]], d = data[[i]])
5.
by_layer(function(l, d) l$compute_aesthetics(d, plot))
4.
ggplot_build.ggplot(x)
3.
ggplot_build(x)
2.
print.ggplot(x)
1.
(function (x, ...) UseMethod("print"))(x)
I'd really like to understand what I'm reading here, and generally what's going on with this code, well enough to troubleshoot.
So what am I reading, and what should my troubleshooting process look like here?