I would like to add a star on top of a barplot to account for statistical significance.
I'm using the script below. However, I keep having error messages although I used the same exact code from another post:
> gg <- ggplot(aes(x=category, y=mean, fill=split, group=split), data=data)
> gg <- gg + geom_bar(stat='identity', position = position_dodge(), width=.5)
> gg <- gg + geom_errorbar(aes(ymin=mean-sd, ymax=mean+sd), position = position_dodge(width=.5), width=.2)
> gg <- gg + scale_x_discrete(labels=c("Accuracy", "Precision", "Recall"))
> gg <- gg + xlab("Precision metrics") + ylab("Mean") + labs (fill="Classifier") + scale_fill_discrete(labels = c("k-NN", "Decision trees"))
> gg <- gg + theme(legend.position = "none")
>
>
> label.df <- data.frame(Group = c("Accuracy"),
+ Value = c(0.99))
>
> gg + geom_text(data = label.df, label = "**")
Don't know how to automatically pick scale for object of type function. Defaulting to continuous.
Error in FUN(X[[i]], ...) : object 'category' not found
Here's the plot. I would like to add the star on top of the Accuracy
red bar.
Any input is appreciated!
PS: I'm providing a dput()
sample below:
> dput(data)
structure(list(mean = c(0.9685, 0.925333333333333, 0.985666666666667,
0.926833333333333, 0.968666666666667, 0.931333333333333), sd = c(0.0150831031289984,
0.0301838809079725, 0.013306639946533, 0.0589488478824367, 0.0147873820085459,
0.0712338870669478), category = structure(c(1L, 1L, 2L, 2L, 3L,
3L), .Label = c("1", "2", "3"), class = "factor"), split = structure(c(1L,
2L, 1L, 2L, 1L, 2L), .Label = c("1", "2"), class = "factor")), row.names = c("a",
"c", "e", "g", "i", "k"), class = "data.frame")