How to Merge Two Unequal Data Frames & Replace NA with 0 in R (Example) | merge & is.na Functions

Publicado el: 16 noviembre 2020
en el canal de: Statistics Globe
4,118
52

How to combine unequal data frames and replace missing data with zero in the R programming language. More details: https://statisticsglobe.com/merge-une...
R code of this video:

data1 <- data.frame(id = 1:5, # Create first data frame
x1 = 5:9,
x2 = 5:1)

data2 <- data.frame(id = 3:7, # Create second data frame
y1 = 20:24,
y2 = 10:14)

data_all <- merge(data1, data2, # Merge data
by = "id",
all = TRUE)

data_all[is.na(data_all)] <- 0 # Replace NA with 0

Follow me on Social Media:
Twitter:   / joachimschork  
Facebook:   / statisticsglobecom  
Reddit:   / joachimschork  
Pinterest: https://www.pinterest.de/JoachimSchork


En esta página del sitio puede ver el video en línea How to Merge Two Unequal Data Frames & Replace NA with 0 in R (Example) | merge & is.na Functions de Duración hora minuto segunda en buena calidad , que subió el usuario Statistics Globe 16 noviembre 2020, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 4,118 veces y le gustó 52 a los espectadores. Disfruta viendo!