Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Engineering Mathematics

Authors: ERWIN KREYSZIG

9th Edition

0471488852, 978-0471488859

More Books

Students also viewed these Mathematics questions

Question

What is Taxonomy ?

Answered: 1 week ago

Question

1. In taxonomy which are the factors to be studied ?

Answered: 1 week ago

Question

1.what is the significance of Taxonomy ?

Answered: 1 week ago

Question

What are the advantages and disadvantages of leasing ?

Answered: 1 week ago