NaN in R Explained (Example Code) | is.nan(), Count, Replace & Remove | Difference Between NaN & NA
Автор: Statistics Globe
Загружено: 2022-04-10
Просмотров: 1766
Описание:
How to deal with NaN values in the R programming language. More details: https://statisticsglobe.com/nan-in-r-...
R code of this video:
5 / 2 # Basic computation in R
0 / 0 # Invalid computation returns NaN
x <- c(5, 9, NaN, 3, 8, NA, NaN) # Create example vector in R
is.nan(x) # Apply is.nan function
which(is.nan(x)) # Get positions of NaN
sum(is.nan(x)) # Count amount of NaN
x_remove <- x[!is.nan(x)] # Remove NaN from vector
x_remove # Print reduced vector to RStudio
x_replace <- x # Replicate example vector
x_replace[is.nan(x_replace)] <- 0 # Replace NaN with 0 in R
x_replace # Print vector with replacement
Follow me on Social Media:
Facebook – Statistics Globe Page: / statisticsglobecom
Facebook – Group for Discussions & Questions: / statisticsglobe
LinkedIn – Statistics Globe Page: / statisticsglobe
LinkedIn – Group for Discussions & Questions: / 12555223
Twitter: / joachimschork
Music by bensound.com
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: