I am fairly new to ggplot, so this probably is very simple question, but I just can't solve it. I use ggplot to build a pie chart based on a factor variable in a data frame. the variable levels are "F" and "M".
hcgen <- ggplot(hc, aes(x = factor(1), fill = gender))
Then I use a blank theme to visualize the chart
hcgen + geom_bar(width = 1) + coord_polar("y") + blank_theme + theme(axis.text.x=element_blank())
I have used different options to add labels but nothing works. I used for example:
geom_text(aes(y = value/3 + c(0, cumsum(value)[-length(value)]), + label = percent(value/100)), size=5)
but this gives the following error
Error in FUN(X[[i]], ...) : object 'value' not found
What am I doing wrong?
value
in your datahc
? The error message indicates that this value is not present in your datahc
. – mnm