Coded by:
plot <- ggplot(data3, aes(x=cond, y=value, fill=variable)) +
geom_boxplot() +
labs(y='Dispersal Distance (km)') +
scale_x_discrete(name='Dispersal Effort',
labels=c('min'='Minimal', 'med'='Medium', 'max'='Maximum')) +
scale_fill_discrete(name="Distance Type",
limits=c("Euc_Dist", "CW_Dist"),
labels=c("Euclidean", "Least Cost Path"))
I want to add significant annotations to each of the grouped data. I.e., between the dispersal effort scenarios. When I've tried adding the geom_signif() I get errors. I've been following this guide. This is the code:
library(ggsignif)
plot + geom_signif(stat='identity',
data=data.frame(x=c(0.7,1.7,2.7),
xend=c(1.3, 2.3, 3.3),
y=c(800,800,800),
annotation=c("*", "*", "*")),
aes(x=x,
xend=xend,
y=y,
yend=y,
annotation=annotation))
plot(plot)
These are the errors:
Error in `geom_signif()`:
! Problem while computing aesthetics.
ℹ Error occurred in the 2nd layer.
Caused by error in `FUN()`:
! object 'variable' not found
Run `rlang::last_error()` to see where the error occurred.
QUESTION: Why aren't they being added?
Sample of my data:
structure(list(cond = structure(c(1L, 1L, 1L, 1L, 1L, 1L), levels = c("min",
"med", "max"), class = "factor"), variable = structure(c(1L,
1L, 1L, 1L, 1L, 1L), levels = c("Euc_Dist", "CW_Dist"), class = "factor"),
value = c(5.25, 3.196, 46.389, 136.696, 131.181, 65.873),
group = c("min Euc_Dist", "min Euc_Dist", "min Euc_Dist",
"min Euc_Dist", "min Euc_Dist", "min Euc_Dist")), row.names = c(NA,6L), class = "data.frame")