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? 回答1: foo <- data.frame(x=rep(1:5,each=20),y=rnorm(100)) with(foo,boxplot(y~x)) 来源: https://stackoverflow.com/questions/30750049/in