【发布时间】:2023-03-25 23:27:01
【问题描述】:
我可以使用
绘制 3 个数据系列的累积分布图library(ggplot2)
a1 <- rnorm(1000, 0, 3)
a2 <- rnorm(1000, 1, 4)
a3 <- rnorm(800, 2, 3)
df <- data.frame(x = c(a1, a2, a3), ggg=factor(rep(1:3, c(1000,1000,800))))
ggplot(df, aes(x, colour = ggg)) +
stat_ecdf()+
scale_colour_hue(name="my legend", labels=c('AAA','BBB', 'CCC'))
但是现在我有大约 100 个观察到的数据,例如 a1,a2 ......a100 有 5000 行,我想要累积分布图,但我不想使用循环,而是想使用 apply 或tapply 和 ggplot 包。
**sample data :df = data.frame(matrix(rnorm(20), nrow=5000,ncol=100)).**
【问题讨论】: