我有一个这样的数据框架:
LR_ID Proc_ID
1 2
1 10
1 10
1 2
2 10
3 10
4 3
5 3
5 10其思想是获得与Proc_ID相关联的频率不同的LR_IDs。
我已经计算了Proc_ID和LR_ID的频率,如下所示:
library(plyr)
count_0 <- count(my_df)这给了我一个类似这样的结果:
LR_ID Proc_ID Freq
1 0 1154
1 1 980
1 2 1256以此类推。我有20个进程I (0到19)和大约800个LR_IDs,所以所有的组合。我想绘制一个轴,其中一个轴是进程id (在本例中是0到19 ),并显示与一个进程id相关联的不同LR_IDs的频率。
发布于 2021-02-12 06:55:37
library(dplyr); library(ggplot2)
my_df %>%
count(LR_ID, Proc_ID) %>%
ggplot(aes(LR_ID, Proc_ID, fill = n, label = n)) +
geom_tile(alpha = 0.8) +
geom_text() +
scale_x_continuous(minor_breaks = NULL) +
scale_y_continuous(minor_breaks = NULL, breaks = 1:800) +
theme_minimal()

样本数据
my_df <- tibble::tribble(
~LR_ID, ~Proc_ID,
1L, 2L,
1L, 10L,
1L, 10L,
1L, 2L,
2L, 10L,
3L, 10L,
4L, 3L,
5L, 3L,
5L, 10L
)https://stackoverflow.com/questions/66163930
复制相似问题