df <- tibble(wspid = c("text","text",1:9,NA),
PID = c("text","text",1:10))
#Function to export a single column inputted in the function argument
export_ids <- function(var) {
export_df <- df %>%
filter(!is.na(var)) %>%
select(var)
write_csv(export_df, "~/Downloads/final_ids.csv")
}
#Calling the function
export_ids(wspid)
I keep getting the same error:
Error: Problem with `filter()` input `..1`.
ℹ Input `..1` is `!is.na(var)`.
x object 'wspid' not found
I suspect there's some issue with the scoping of the function but no matter what combinations I try-- such as defining the tibble within the function or referencing the tibble directly within the function (as in, df$var) I still get an error.