I'm trying to use a logical operator to subset in a function as follows:
iris$Species <- as.character(iris$Species)
mySubsetFunction <- function(df, species){
dfSubset <- subset(df, Species==species)
return(dfSubset)
}
mySubsetFunction(iris, species="setosa" | species="virginica")
This returns an error:
Error: unexpected '=' in "mySubsetFunction(iris, species="setosa" | species="
How can I set up the arguments of the function to accept logical operators?