my function is going to take data and column name from user.
column name must be passed only like : column or my column (ie, no "" s only backticks if column name is multi words)
at part of my function I need to check for missing values in that column and replace them with "missed".
myfun <- function(data, column){
library(tidyverse)
data <- as.tibble(data)
data %>%
mutate(across(.cols = {{column}}, .fns = as.character)) %>%
replace_na(list({{columns}} = "missed"))
}
new_df <- airquality %>%
myfun(Ozone)
I used {{}} before and I had no issues passing column names like airquality example above. Now at part of my actual function, I need to replace na s . the format above does not work with replace_na() .
any idea how to fix this?