I'm sure this is an elementary question but I'm trying to build a function that takes in a column name as an argument. When I run the function with the column name as a variable, it doesn't recognize it. It just creates a column aptly named 'column'. Is there a trick I'm missing?
add_category <- function(file_name, column) {
file_name <- file_name %>%
mutate( column = tolower(column),
Category = case_when (
str_detect(column,"accessories")==TRUE ~ "Accessories"
))
}Sort_Filter_10 <- add_category(Sort_Filter_10, Page)