In R, how to make a boxplot?

笑着哭i 提交于 2019-12-20 07:46:12

问题


My input table has two columns like this:

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

I want to make a boxplot of the y values for each individual x value. The x values are limited to 1, 2, 3.

Here is my R code:

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)

How to correct my code?


回答1:


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



来源:https://stackoverflow.com/questions/30750049/in-r-how-to-make-a-boxplot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!