I am analyzing data in R with many different data sets and I want to send in dummy variables to a function which then subsets the main data set and outputs the mean of a variable in the subsets.
For instance, my data set is named "two" and my dummy variable is "over50" and my function is:
getMean <- function(varName) {
   sub1 <- two[two$varName == 1, ]
   sub2 <- two[two$varName == 0, ]
   print(mean(sub1$return)
   print(mean(sub2$return)
}
However, when I call getMean(over50) I do not get the answer expected.
Is there a way to translate the function input into var names so I can do this dynamically? Or do I have to manually do these calculations?