I am trying to write a simple function to avoid duplicating the same piece of code again and again. My code is something similar to this - and I need to call the function about 10 times (like I am doing below with Day and Wind - it is a column in a dataframe, and I need to be able to do some processing using it within the function. I get the object not found error every time. Could someone please advice on which basic concept I am getting wrong here? Thanks
air_tib <- as_tibble(airquality)
test_function <- function(myvar) {
filter(
air_tib,
myvar > 10
)
}
new_df_day <- test_function(myvar=Day)
new_df_wind <- test_function(myvar=Wind)
Error: Problem with `filter()` input `..1`.
x object 'Day' not found
ℹ Input `..1` is `myvar > 10`.