0 votes
in Technology by (228k points)

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 votes
by (228k points)
Let’s take this vector:

Now, let’s write the function to impute the values:
missing_mean <- function(arr){
ifelse(is.na(arr),mean(arr,na.rm = T),arr)

Related questions

0 votes
1 answer 27 views
0 votes
1 answer 33 views
0 votes
1 answer 30 views
0 votes
1 answer 39 views