繁体   English   中英

在R中,如何制作箱形图?

[英]In R, how to make a boxplot?

我的输入表有两列,如下所示:

x    y
1    187
2    235
3    857
3    253
2    955
1    267

我想为每个单独的x值制作一个y值的箱线图。 x值限制为1、2、3。

这是我的R代码:

data=read.table("input.txt")
arr=array(dim=3)
for (i in 1:3)
{
    arr[i]=data[data.x==i,"y"] // This line raises warnings.
}
boxplot(arr)

如何更正我的代码?

foo <- data.frame(x=rep(1:5,each=20),y=rnorm(100))
with(foo,boxplot(y~x))

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM