What I would like to do is the geom_bar () label in the following example with the corresponding data labels. So far, I can only get one or the other:
dput ():
x <- structure(list(variable = c("a", "b", "c"), f = c(0.98, 0.66,
0.34), m = c(0.75760989010989, 0.24890977443609, 0.175125)), .Names = c("variable",
"f", "m"), row.names = c(NA, 3L), class = "data.frame")
ggplot(x, aes(variable, f, label=paste(f*100,"%", sep=""))) +
geom_bar() +
geom_text(size=3, hjust=1.3, colour="white") +
geom_bar(aes(variable, m, label=paste(m*100,"%",sep="")), fill="purple") +
coord_flip()

See how there is a data label on the inside of black. In the same plot, I would like to do the same inside violet.
source
share