This is an example of my data
df = data.frame(id = rep(1:3, each = 1),
test = sample(40:100, 3),
Sets = c(NA,4,4),
CheWt = c(NA,4,NA),
LatWt = c(NA,5,5))
I'd like to turn all the NA
to 0
in columns which have "Wt"
in the header. I am trying to use dplyr and mutate
across
df = df%>%
mutate(across(contains("Wt"), replace(is.na(), 0)))
This is the error
Error: Problem with `mutate()` input `..1`.
x argument "values" is missing, with no default
i Input `..1` is `(function (.cols = everything(), .fns = NULL, ..., .names = NULL) ...`.