Q:

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. e.g setosa. it should show 50 entries. I tried aggregate but didnt work. It is the equivalent and of the WHERE clause in SQL. 

A:

You are looking for the subset command.
data(iris)

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

