I did my analysis with a bootstrap approach. Now I would like to plot the "significance" in a box plot. But I get all the time the same error message: Error: Aesthetics must be either length 1 or the same as the data (18): colour Can someone help me? DataPlot_7 is an example data frame:
df1 <- data.frame(a = c(1, 1:2,2), b = c(60, 61, 61, 60))
DataPlot_7 <- data.frame(DeltaFace = c(48.58, 0.70, -1.54, 1.29, 64.29, 12.00, 60.87, 4.83), Manipulation = as.factor(c("positive", "neutral", "negative","negative","positive", "positive", "neutral","negativ")), Condition = as.factor(c("1", "2", "1", "2", "2", "1", "2", "1")))
Plot.Mean.Diff.Face.Manipulition_4 <- ggplot(data = DataPlot_7, aes(x = DataPlot_7$Condition, y = DataPlot_7$DeltaFace, color=DataPlot_7$Condition)) +
geom_boxplot(alpha = 0.6,outlier.colour = "#1F3552", outlier.shape = 20, width = 30)+
facet_wrap(~Manipulation, ncol = 2)+
scale_x_discrete(name = "X" ) +
scale_y_continuous(name = "Y", breaks = seq(-100, 100, 25), limits=c(-100, 100)) +
ggtitle("title") +
theme_set(theme_apa())+
theme(plot.caption = element_text(hjust = 0.2),
axis.title.x=element_blank(),
axis.text.x=element_blank())+
scale_fill_brewer(palette = "Accent") +
theme(legend.position="right")+
geom_line(data = df1, aes(x = a, y = b)) + annotate("text", x = 2.5, y = 62, label = "*", size = 8)
Plot1 <- Plot.Mean.Diff.Face.Manipulition_4
The goal would be to get some horizontal lines from condition to condition and if it was significant, that I could manually set a star on the line
I found this approach on StackOverflow for excample:
pp <- ggplot(mtcars, aes(factor(cyl), mpg)) + geom_boxplot()
df1 <- data.frame(a = c(1, 1:3,3), b = c(39, 40, 40, 40, 39))
pp + geom_line(data = df1, aes(x = a, y = b)) + annotate("text", x = 2, y = 42, label = "*", size = 8)
But every time I'm trying to change it to my dataset I get the described Error message.