mutate_at(vars(contains("数")),as.numeric) mutate_if(str_detect(colnames(.), "数"),as.numeric) mutate_if(is.character,as.numeric) 在dplyr中,选择包含“ Sepal”的变量,并将NA分配给Species为“ setosa”的那些行: iris %>% mutate_at(vars(contains("Sepal")), funs(ifelse(Species == "setosa", NA, .))) iris %>% mutate_at(vars(contains("Sepal")), funs(na_if(Species, "setosa")))