I have a little function that searches though user defined column
of a dataframe relying on dplyr
. In the current form below it accepts the column argument in non-standard evaluation - without quotes (e.g. scenario
instead of "scenario"
in standard evaluation).
search_column <- function(df, column, string, fixed = TRUE){
df <- dplyr::select_(df, deparse(substitute(column)))
df <- distinct(df)
return(grep(string, df[[1]], fixed = fixed, value = TRUE))
}
Is there a way to make the function work no matter how the user enters the column name, i.e. in standard or non-standard evaluation?