-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMissingData.Rmd
More file actions
30 lines (22 loc) · 1.2 KB
/
MissingData.Rmd
File metadata and controls
30 lines (22 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# SOLVING MISSING DATA FROM
# Importing Dataset
dataset = read.csv('editeddata.csv')
# Taking Care of missing Data form the Dataset
# We are using Mean to fill the empty postions in the datasets here
------------------------------------------------------------------------------------
# SOLVING FROM MEAN FORMULA'S
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)
-------------------------------------------------------------------------------------
# SOLVING USING MEDIAN FORMULA'S
data$Age = ifelse(is.na(data$Age),
ave(data$Age, FUN = function(x) median(x, na.rm = TRUE)),
data$Age)
data$Salary = ifelse(is.na(data$Salary),
ave(data$Salary, FUN = function(x) median(x,na.rm = TRUE)),
data$Salary)
-------------------------------------------------------------------------------------