您可以这样做
library(tidyverse)
df %>%
group_by(Disease, days) %>%
summarise(Freq = n()) %>%
ggplot(aes(days, Freq, colour = Disease)) +
geom_line()
样本数据
df <- read.table(text =
"Disease days
AA 7
AA 5
AA 5
AA 15
AA 4
AA 15
AA 5
AA 7
BB 4
BB 3
BB 11
BB 6
BB 12
BB 6
BB 9
BB 20
BB 4
BB 2", header = T)