I have a dataset with a named column. The name of the column is also in a variable. I would like to be able to select all rows that satisfy a condition on the column "col".
Here I would like to select all rows whose value in the "col" column matches the condition "< 2".
name = "col"
dataset = data.frame(col = 1:3)
I tried to use "eval" in subset, or the "select" function of the dplyr package, but it does not do what I want (or I misused it).
Is there a simple way to do this?
dataset[ dataset[[ name ]] < 2, ]