我的函数将从用户处获取数据和列名
在我的函数中,我需要判断该列中缺少的值,并用"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)
我以前使用过{{}}
,我在传递像上面的空气质量示例这样的列名时没有问题.现在,在我的实际功能中,我需要替换na s.上述格式不适用于replace\u na()
你知道怎么解决这个问题吗?