【发布时间】:2020-07-22 07:38:24
【问题描述】:
我有一组像这样的点,我正在尝试根据它们与平均值的距离将它们分组或聚类为大小相等的四组。
df <- data.frame(x = rnorm(50, 0, 1),
y = rnorm(50, -0, 0.7))
ggplot(data = df, aes(x = x, y = y)) +
geom_point() +
geom_abline(slope = 0.7, intercept = 0) +
geom_abline(slope = -0.7, intercept = 0)
在这种情况下,我希望根据每个点相对于平均值的距离(此处为 (0,0))以及该距离的趋势是向上、向下、向左还是向右,为每个点分配一个组.感谢您的帮助。
【问题讨论】:
标签: r group-by cluster-analysis partitioning partition