简体   繁体   中英

Extracting rows from data frame with variable string condition in R

Take iris as the data frame, I want to extract all rows and column variables (Petal.Length,Petal.Width,Sepal.Length,Sepal.Width) that have species as a specific value. eg setosa. it should show 50 entries. I tried aggregate but didnt work. It is the equivalent and of the WHERE clause in SQL.

You are looking for the subset command.

data(iris)

dat<-subset(iris,subset=Species=='setosa')

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