我正在尝试使用比例作为y轴而不是计数来制作分面直方图。几个问题:
如何为此添加垃圾箱以指出预定义的费用(例如,$ 1,$ 10,$ 50,$ 100)?
df <- data.frame(type = factor(rep(c("A","B"), each = 5000)),
cost = c(rnorm(1000, mean = 25), rnorm(1000, mean = 90)))
ggplot(df, aes(x = cost)) +
geom_histogram(aes(y = ..count../sum(..count..)*100), binwidth = 10) +
facet_grid(type ~ .)