I have a data frame and some columns have NA values.
NA
How do I replace these NA values with zeroes?
An easy way to write it is with if_na from hablar:
if_na
hablar
library(dplyr) library(hablar) df <- tibble(a = c(1, 2, 3, NA, 5, 6, 8)) df %>% mutate(a = if_na(a, 0))
which returns:
a 1 1 2 2 3 3 4 0 5 5 6 6 7 8