Replacing NA's in a dataframe/tibble

That's a good solution. I've been using:

df[is.na(df)] <- 0 

but it does not fit in a pipe chain very smoothly. I really like

mutate_if(is.numeric, funs(replace_na(., 0)))

thanks for sharing what you figured out!

6 Likes