Answers for "replace na with 0 in r column dplyr"

R
7

r replace na with 0

d[is.na(d)] <- 0
Posted by: Guest on August-08-2020
1

replace na with 0 in R

library(dplyr)
#Replacing missing values with 0 in columns 'x' and 'y' of the tibble dataframe 'df'
df %>% 
  replace_na(list(x = 0, y = 0))
Posted by: Guest on August-16-2020
0

replace any NA in a data frame in r

a = data.frame(a=c(NA,1,2,NA), b=c(1,1,2,NA),c=c(NA,NA,2,NA))
for (i in 1:3){
  a[which(is.na(a[,i])),i] = 0
}
Posted by: Guest on October-09-2020

Browse Popular Code Answers by Language