Say I have the below df
library(ggplot2)
library(data.table)
# dummy data
df <- data.table(revenue = rnorm(1e4, mean = 100, sd = 1)); df
revenue
1: 100.01769
2: 98.31862
3: 99.78464
4: 100.17670
5: 99.31678
---
9996: 99.47635
9997: 98.27383
9998: 99.48378
9999: 100.06227
10000: 99.13972
and that I plot a histogram with a vline denoting the mean
# mean of x axis
x <- df[, mean(revenue)]
# plot
ggplot(df, aes(x = revenue)) +
geom_histogram(aes(y = (..count..) / sum(..count..))) + # turn count into %
geom_vline(aes(xintercept = x), col = 'red', size = 1)
The above is fine. However, when trying to add a label showing the mean, I am unsure what to enter for y in geom_label(aes(x = x, y = ?)...:
# plot
ggplot(df, aes(x = revenue)) +
geom_histogram(aes(y = (..count..) / sum(..count..))) + # turn count into %
geom_vline(aes(xintercept = x), col = 'red', size = 1) +
geom_label(aes(x = x, y = ?)
, label = x
)
I have tried small numbers such as 0.025 (after looking at the density from the previous plot) but then R gets stuck and creating the plot and never finishes. Say, I'd like to position the numeric label at where y axis = 0, then what value should I put into y = ?
Thank you

