[英]How to select a subset of rows and columns from a data.frame
I have this 我有这个
d[d$Age > "2", ]
and it returns all the rows that have an Age of over 2, but I want to only return the values in a few of the columns, say d$X and d$Y, not all of them. 并且它返回Age年龄超过2的所有行,但我想只返回几个列中的值,比如d $ X和d $ Y,而不是全部。
anyway i can do this? 无论如何我能做到这一点?
Thanks 谢谢
d[d$Age > "2", c("X","Y")]
另一种方式
subset(d, Age > "2", select=c(X, Y))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.