Question: Stuck on writing a function in R # First, let's write a function `get_col_info()` that takes as parameters a # column name and a dataframe.

Stuck on writing a function in R

# First, let's write a function `get_col_info()` that takes as parameters a # column name and a dataframe. If the values in the column are *numeric*, # the function should return a list with the keys: # - `min`: the minimum value of the column # - `max`: the maximum value of the column # - `mean`: the mean value of the column # If the column is *not* numeric and there are fewer than 10 unique values in # the column, you should return a list with the keys: # - `n_values`: the number of unique values in the column # - `unique_values`: a vector of each unique value in the column # If the column is *not* numeric and there are 10 or *more* unique values in # the column, you should return a list with the keys: # - `n_values`: the number of unique values in the column # - `sample_values`: a vector containing a random sample of 10 column values # Hint: use `typeof()` to determine the column type

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!