Dear all,
Can someone explain to me why first code chunk does not work but the second one works? Thank you.
library(tidyverse)
rownames_to_column(mtcars, var = "car") %>%
mutate(across("car"), ~str_remove_all(., "\\d"))
#> Error: Problem with `mutate()` input `..2`.
#> i `..2 = ~str_remove_all(., "\\d")`.
#> x `..2` must be a vector, not a `formula` object.
Created on 2022-01-14 by the reprex package (v2.0.1)
mtcars %>%
mutate(across(everything(), ~ifelse(.=="0", NA, as.character(.))))
Created on 2022-01-14 by the reprex package (v2.0.1)