如何在R中绘制行方式矩阵?

pet*_*bel 1 r matrix boxplot

我有matrix8列.对于每一行,我想绘制一个单一的箱图.我更喜欢箱形图在一个地块中.因此,以下示例应生成4个箱图(每个8个值) - 全部在单个图像中.

数据示例:

> data[2:5,]
     [,1] [,2] [,3]      [,4]      [,5]      [,6]      [,7]      [,8]     
[1,] 0.6  0.5  0.5357143 0.5357143 0.5357143 0.5357143 0.5357143 0.5185185
[2,] 0.5  0.5  0.5357143 2.5357143 0.5357143 0.5357143 0.5357143 0.5185185
[3,] 0.5  0.7  0.5357143 0.5357143 0.5357143 0.5357143 0.5357143 0.5185185
[4,] 0.5  0.5  1.5357143 0.5357143 0.5357143 0.5357143 0.5357143 0.5185185
Run Code Online (Sandbox Code Playgroud)

到目前为止,我已经尝试过:

> boxplot(data[2:5,])
Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 
  'x' must be atomic
Run Code Online (Sandbox Code Playgroud)

这个方法来自这个SO帖子:

> boxplot(as.list(as.data.frame(data[2:5,])))
Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 
   'x' must be atomic
Run Code Online (Sandbox Code Playgroud)

我一直在苦苦挣扎.你能给我一些暗示吗?

EDIT1:

> dput(data[2:5,])
structure(list(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.535714285714286, 
    0.535714285714286, 0.535714285714286, 0.535714285714286, 
    0.535714285714286, 0.535714285714286, 0.535714285714286, 
    0.535714285714286, 0.535714285714286, 0.535714285714286, 
    0.535714285714286, 0.535714285714286, 0.535714285714286, 
    0.535714285714286, 0.535714285714286, 0.535714285714286, 
    0.535714285714286, 0.535714285714286, 0.535714285714286, 
    0.535714285714286, 0.518518518518518, 0.518518518518518, 
    0.518518518518518, 0.518518518518518), .Dim = c(4L, 8L))
Run Code Online (Sandbox Code Playgroud)

mto*_*oto 6

要从矩阵中绘制箱图,我们可以使用以下boxplot.matrix函数:

boxplot.matrix(data, use.cols = FALSE)
Run Code Online (Sandbox Code Playgroud)