I want to substitute NA by 0 in 20 columns. I found this approach for 2 columns, however I guess it\'s not optimal if the number of columns is 20. Is there any alternative a
Here is a tidyverse way to replace NA with different values based on the data type of the column.
tidyverse
library(tidyverse) dataset %>% mutate_if(is.numeric, replace_na, 0) %>% mutate_if(is.character, replace_na, "")