r - Create data labels for frequency plot in ggplot2? -


in this question, frequency figure can created using ggplot. example:

f <- factor(sample(letters[1:5], 100, r=t)) h <- table(f) / length(f) dat <- data.frame(f = f) ggplot(dat, aes(x=f, y=..count.. / sum(..count..), fill=f)) + geom_bar() 

how obtain data labels each individual bar within figure?

thank you.

you can add geom_text():

library(ggplot2) ggplot(dat, aes(x=f, y=..count.. / sum(..count..), fill=f)) +    geom_bar() +   geom_text(stat = "count", aes(label=..count../100)) 

enter image description here


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -