给定一些标准的子集 [英] Subsetting a data.frame given some criteria
本文介绍了给定一些标准的子集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何仅返回满足R中的年龄标准的高度?
How do I return only the Heights which satisfy an Age criterion in R?
ie
Age Height
1 0.5
1 0.6
1 0.7
1 0.6
4 2.0
4 2.3
4 2.3
我只想要对应于Age = 4.的高度。允许我这样做?
I want only the heights which correspond to an Age == 4. Which function in R would allow me to do that?
推荐答案
尝试这个:
dat <- data.frame(Age=c(1,1,1,1,4,4,4),Height=c(0.5,0.6,0.7,0.6,2.0,2.3,2.3))
dat[dat$Age==4,2]
这篇关于给定一些标准的子集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文