如何在R中散布矩阵的列?

时间:2018-11-17 00:12:46

标签: r matrix scatter-plot

我有矩阵X:

> X
           [,1]         [,2]         [,3]        [,4]        [,5]
[1,] 0.02253900 -0.012803512 -0.013251695 -0.01728001  0.07287110
[2,] 0.07233855 -0.004631113 -0.010130339 -0.01441094  0.06592686
[3,] 0.05094459  0.030918198  0.032321927  0.01459335  0.02315130
[4,] 0.05484819 -0.019442784 -0.017389669  0.01044847  0.05890890
[5,] 0.02164396 -0.030857845  0.007139042 -0.08033237 -0.02356664
[6,] 0.02388358 -0.007537327  0.018435093 -0.01349781  0.04029035

> class(X)
"matrix"

我想要做的是scatterplot 每列都按x的每个值分组

这是我失败的尝试

ggplot(aes(x = 1:5, y = X)) + geom_point()

1 个答案:

答案 0 :(得分:0)

这是一个基本的R解决方案:

plot(rep(1:ncol(x), each=nrow(x)), x)