【发布时间】:2020-02-18 21:54:48
【问题描述】:
假设我有数据D。我把cut这个数据分成了3个。如何为 R 图中的每条数据分配不同的颜色?
注意:我对任意数量的数据切割的功能性答案感兴趣。
这是我的数据和 R 代码(没有成功):
# DATA
D <- read.csv("https://raw.githubusercontent.com/rnorouzian/m/master/t.csv", h = TRUE)
# cut in 3 pieces
g <- table(cut(D$time,
breaks = c(-Inf, 4, 12, Inf),
include.lowest=TRUE))
# color DATA based on pieces: [0-4], [6-12], [24-40]
plot(table(D$time), col = (1:3)[g])
【问题讨论】: