简体   繁体   中英

In R, how to make a boxplot?

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?

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

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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