[R] ggplot2: ..n.. and ..count.. in geom_text
G.Maubach at weinwolf.de
G.Maubach at weinwolf.de
Tue Apr 18 19:06:47 CEST 2017
Hi All,
I have the following code:
-- cut
(g03_02_p02 <- ggplot(data = d_kzb_input) +
geom_bar(
mapping = aes(x = v03_02_r01, y = round(..prop.. * 100, 0)),
fill = c_ww_palette["blue"]) +
scale_y_continuous(limits = c(0, c_y_limit)) +
theme_classic() +
ggtitle(paste0("Question 3",
"(n = ", <<cases>>, ")")) + # How can I refer to the number of cases
for this plot? Is there something like "..n.."?
xlab("Orders") +
ylab("Percent") +
geom_text(
aes(label = ..count..), # How can I refer to the counts for the
labels of the columns?
color = "white",
position = position_stack(vjust = 0.5)))
-- cut --
I would like to refer to the internal statistics of the geom_bar():
How can I refer to the number of cases for this plot? Is there something
like "..n.."?
How can I refer to the counts for the labels of the columns?
Kind regards
Georg
More information about the R-help
mailing list