【发布时间】:2020-10-22 11:38:07
【问题描述】:
我有这个 df:
ID values Pop1
1 PDAC1 611648 Nafr
2 PDAC1 322513 Nafr
3 PDAC2 381089 Nafr
4 PDAC2 16941 Nafr
5 PDAC3 21454 Jud
6 PDAC3 658802 Jud
我想在“Pop1”列上使用 facet_wrap 制作两个直方图:
ggplot(all.samples2) +
aes(x = values, fill = Pop1, colour = Pop1, after_stat(density)) +
geom_histogram(bins = 30L) +
theme_minimal() +
facet_wrap(vars(Pop1)) +
theme_bw() +
theme(aspect.ratio=1)
但我不想使用这些值,而是使用每个人口中的百分比。
所以例如对于Pop1 = Nafr,我的直方图将显示 bin 0 到 300000 中 25% 的数据,bin 300000 到 600000 中 50% 的数据以及 bin 600001 到 900000 中 25% 的数据。
我该怎么做?
谢谢
【问题讨论】: