I've a question in regards to ggplot. Below is my script:
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",c("k-NN","Decision trees"))
gg + theme_classic()
And
here is the plot produced. My question is simple, as I would like to change 1
for k-NN
and 2
for Decision trees
in the legend under Classifier
.
I've tried the following but I'm getting error messages:
> gg <- ggplot(aes(x=category, y=mean, fill=split (labels=c("k-NN","Decision trees")), 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")
> gg + theme_classic()
Error in deparse(...) :
unused argument (labels = c("k-NN", "Decision trees"))
Hope I can get some help!