我遇到以下问题,我希望根据另一列的值计算fill
参数。下面的可复制示例:
library(tidyverse)
df <- tibble(a = rbeta(1000, 10, 2),
b = rbinom(1000, 1, .8))
df %>%
ggplot() +
geom_histogram(aes(x = a, fill = "average of df$b by bin"), color = "black", binwidth = 0.05, boundary = -0.05) +
scale_x_continuous(labels = scales::percent, breaks = seq(0, 1, .05))