Imagine you have a simple dataset like this one:
ive
region Edad
1 Española 23
2 Española 37
3 Española 40
4 Española 21
5 Africana 29
6 Española 42
7 Europea 29
8 Española 25
9 Española 32
10 Española 20
I am interested on performing a barplot for the variable region
classifying by colour. So I created the following piece of code:
g1 <- ggplot(ive, aes(x=reorder(ive$region, -table(ive$region)[ive$region])))
g1 + geom_bar(aes(fill=ive$region)) + geom_text(stat='count',aes(label=..count..),vjust=-0.7) + xlab("")
But the legend of the plot displays ive$region
and I want it to display a customized title.
I am almost sure it is a silly question but I have been traying to solve it for 2 days and I dont find the way to do it.
Thank you, Álvaro