How to plot a subset of a data frame in R?

前端 未结 4 2237
温柔的废话
温柔的废话 2020-12-13 05:48

Is there a simple way to do this in R:

plot(var1,var2, for all observations in the data frame where var3 < 155)

It is possible by creat

4条回答
  •  情歌与酒
    2020-12-13 06:20

    This is how I would do it, in order to get in the var4 restriction:

    dfr<-data.frame(var1=rnorm(100), var2=rnorm(100), var3=rnorm(100, 160, 10), var4=rnorm(100, 27, 6))
    plot( subset( dfr, var3 < 155 & var4 > 27, select = c( var1, var2 ) ) )
    

    Rgds, Rainer

提交回复
热议问题