如何在R中绘制数据帧的子集? [英] How to plot a subset of a data frame in R?

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

问题描述

在R中是否有一种简单的方法:

Is there a simple way to do this in R:

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

可以通过创建新数据newdata <- data[which( data$var3 < 155),]来实现,但是随后我必须重新定义所有变量newvar1 <- newdata$var1等.

It is possible by creating a new data newdata <- data[which( data$var3 < 155),] but then I have to redefine all the variables newvar1 <- newdata$var1 etc.

推荐答案

with(dfr[dfr$var3 < 155,], plot(var1, var2))应该可以解决问题.

编辑有关多个条件:

with(dfr[(dfr$var3 < 155) & (dfr$var4 > 27),], plot(var1, var2))

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

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