Extract rows from R data frame based on factors (strings) Try using the subset function. This site provides a good reference: HowtoInR my_data = subset(my_data, gender == "male") Related Posts: Remove an entire column from a data.frame in R Remove an entire column from a data.frame in R How can a add a row to a data frame in R? How to resolve TypeError: ‘No Numeric Data to Plot’, when numeric data exists in Python How can a add a row to a data frame in R? Error in x[j] : invalid subscript type ‘list’ while using subset in R Replacing values from a column using a condition in R variable lengths differ in R using lm number of rows of result is not a multiple of vector length (arg 2) in R How to split a data frame? Error – replacement has [x] rows, data has [y] Error in .subset2(x, i, exact = exact) : subscript out of bounds in R R error: “New Column would leave holes after existing columns” How to convert a table to a data frame Convert a row of a data frame to vector