Skip to content

Instantly share code, notes, and snippets.

@JoseRFJuniorLLMs
Created January 27, 2018 05:48
Show Gist options
  • Save JoseRFJuniorLLMs/a8c43ab9a39020db83c0c2ea8c098b2f to your computer and use it in GitHub Desktop.
Save JoseRFJuniorLLMs/a8c43ab9a39020db83c0c2ea8c098b2f to your computer and use it in GitHub Desktop.
# Data Preprocessing
# Importing the dataset
dataset = read.csv('Data.csv')
# Taking care of missing data
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