Skip to content

Instantly share code, notes, and snippets.

@amkurian
Created February 29, 2020 05:31
Show Gist options
  • Save amkurian/d074e8c9856eac4a8beacf6e16d35c7a to your computer and use it in GitHub Desktop.
Save amkurian/d074e8c9856eac4a8beacf6e16d35c7a to your computer and use it in GitHub Desktop.
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