Question: Please answer this question in R, as requested by the question. a. Write an R function called descr_stats that, given a data frame, returns the
Please answer this question in R, as requested by the question.

a. Write an R function called descr_stats that, given a data frame, returns the number of missing values per each variable, the mean and the sample variance for all the numeric variables, and the most frequent value forthe categorical variables (2 points). The function should return a list of three elements: - the first element is an atomic vector containing integers which represent the number of missing values in each variable. The length of this vector must be equal to the number of variables in the data frame. Add names to the elements of the vector for better readability [1 point). - The second element is a matrix containing as many rows as the number of numeric variables in the data frame, and two columns. The first column should contain the mean and the second column the sample varianceAdd names to rows and columns for better readability (2 points]. - The third element is a character vector containing the most frequent value of each categorical variable. Add names to the elements of the vector for better readability (1 point). b. Create three data frames: one that contains only 3 numeric variables and some NAs, one that contains only 3 categorical variables and some Mills, and one that contains 3 numeric and 3 categorical variables and no NAs (3 points). c. Test yourfunction on the three data frames (1 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
