我可以使用 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)).**