在R中,如何制作箱形图? [英] In R, how to make a boxplot?

查看:187
本文介绍了在R中,如何制作箱形图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

My input table has two columns like this:

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



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

I want to make a boxplot of the y values for each individual x value. The x values are limited to 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))

这篇关于在R中,如何制作箱形图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆