Replace NA with 0 in R | 2 Examples for Vector & Data Frame

Veröffentlicht am: 07 September 2018
auf dem Kanal: Statistics Globe
9,511
112

How to replace NA values with 0 in R programming (2 examples).
R code of this video:

##### Replace NA with 0 in vector #####

Example vector
x <- c(4, 9, 1, NA, 5, NA, NA)

Replace NA
x[is.na(x)] <- 0

##### Replace NA with 0 in data.frame

Example data.frame
data(airquality)

Replace NA
airquality[is.na(airquality)] <- 0


Find more explanations at https://statisticsglobe.com/r-replace...

Also, have a look at this post, in which I am explaining the is.na R function in more detail: https://statisticsglobe.com/r-is-na-f...

Additional information: The procedure that is shown in the video can also be applied to change NA to any other value. Just replace the 0 - as shown in the video - with another value.


Auf dieser Seite können Sie das Online-Video Replace NA with 0 in R | 2 Examples for Vector & Data Frame mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Statistics Globe 07 September 2018 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 9,511 Mal angesehen und es wurde von 112 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!