Skip to content

Instantly share code, notes, and snippets.

@FranciscusRenatus
Last active June 20, 2017 16:24
Show Gist options
  • Save FranciscusRenatus/50f6dacc420adb5c4cd0f3d1cc7f9bcd to your computer and use it in GitHub Desktop.
Save FranciscusRenatus/50f6dacc420adb5c4cd0f3d1cc7f9bcd to your computer and use it in GitHub Desktop.
#Taking care of missing data using R
dataset$Age = ifelse(is.na(dataset$Age),
ave(dataset$Age, FUN= function(x) mean(x, na.rm = TRUE)),
dataset$Age)
dataset$Salary = ifelse(is.na(dataset$Salary),
ave(dataset$Salary, FUN= function(x) mean(x, na.rm = TRUE)),
dataset$Salary)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment