in Technology by

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
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)
}

Related questions

0 votes
    You are given a data set consisting of variables with more than 30 percent missing values. How will you deal with them?...
asked Apr 26, 2021 in Technology by JackTerrance
0 votes
    Which technologies and languages would you need to develop a project from scratch?...
asked Jun 13, 2021 in Education by Editorial Staff
0 votes
    I am working with this data set: u <- c(31,63,95,117,127,143,151.5,157) v <- c(98.5,103.8,107.5 ... me to find the best fitting model? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    You are given a dataset on cancer detection. You have built a classification model and achieved an accuracy of 96 percent ... with your model performance? What can you do about it?...
asked Apr 27, 2021 in Technology by JackTerrance
0 votes
    What will do you with a missing value in an observation? Options 1 from the point of definition onward in the ... the function. Tin Select the correct answer from above options...
asked Nov 28, 2021 in Education by JackTerrance
0 votes
    Before starting to enter data in a table, you must create the: a. Design of the table c. Database from which to ... d. All of these Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    The _________ function can be used to select columns of a data frame that you want to focus on. (a) ... Operations of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    What is the added value for learning F# when you are already familiar with LISP? JavaScript questions and ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    Can I specify my own distance function using scikit-learn K-Means Clustering? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
+1 vote
    If you have to replace your current on-premise services in the form of virtual machines, then you can use Microsoft Azure cloud categorized as ____________....
asked Oct 20, 2020 in Technology by JackTerrance
+1 vote
    If you have to replace your current on-premise services in the form of virtual machines, then you can use Microsoft Azure cloud categorized as ____________....
asked Oct 20, 2020 in Technology by JackTerrance
0 votes
    Why do we obtain five missing values from the following lines of code? x <- 1:5 x[NA]...
asked Oct 16, 2020 in Technology by JackTerrance
0 votes
    It is wise to use secondary indexes on the columns you want to be querying on has few unique values (1)True (2)False...
asked May 7, 2021 in Technology by JackTerrance
0 votes
    It is wise to use secondary indexes on the columns you want to be querying on has few unique values (1)True (2)False...
asked Apr 16, 2021 in Technology by JackTerrance
0 votes
    If you want to make some information prominent in your document what a type of change will you perform? Select the correct answer from above options...
asked Dec 6, 2021 in Education by JackTerrance
...