简体   繁体   中英

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.

anyway i can do this?

Thanks

d[d$Age > "2", c("X","Y")]

另一种方式

subset(d, Age > "2", select=c(X, Y))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM