[英]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. 以虹膜为数据框,我想提取所有具有种类作为特定值的行和列变量(Petal.Length,Petal.Width,Sepal.Length,Sepal.Width)。 eg setosa.
例如setosa。 it should show 50 entries.
它应该显示50个条目。 I tried aggregate but didnt work.
我试过聚合,但没有工作。 It is the equivalent and of the WHERE clause in SQL.
它与SQL中的WHERE子句等效。
You are looking for the subset command. 您正在寻找subset命令。
data(iris)
dat<-subset(iris,subset=Species=='setosa')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.