Hi all, Below is the simple filtering that is done on Iris data set
iris_new <- iris %>% filter(Species == "setosa")
But I am trying to create a function where the functions takes data, category as input and then filters. Example
## df is a dataframe, cat is column on which filtering is applied and cat_val is the categorical values
filter_fun <- function(df, cat, cat_val){
res <- df %>% filter(cat == "cat_val")
return(res)
}
So when I try running below, I get error. Appreciate if anyone could help me whtat wrong I am doing here
filter_fun(iris, Species, "setosa")