0
You want to clean the data before fitting your model. What would you do to replace these missing values? Develop your own function.

Open 1 Answers 38 Views Technology

You are solving a data science problem that is ridden with many missing values. You want to clean the data before fitting your model. What would you do to replace these missing values? Develop your own function.

1 Answer

0
Let’s take this vector:

arr<-c(1,2,4,NA,NA,11,NA,10)
Now, let’s write the function to impute the values:
missing_mean <- function(arr){
ifelse(is.na(arr),mean(arr,na.rm = T),arr)
}
by (277k points)
...