Question: R problem opiod Create a function named county. summary that has two arguments: df and county. The opiod data frame will be passed to the

R problem

opiod

R problem opiod Create a function named county. summary that has twoarguments: df and county. The opiod data frame will be passed to

Create a function named county. summary that has two arguments: df and county. The opiod data frame will be passed to the argument df , and a county in Connecticut will be passed to the county argument as a character. See below for some examples of county.summary in action. Your function, county.summary , should return a list with the following information: total deaths in the specified county, mean age of death in the specified county, median age of death in the specified county a demographics data frame for county deaths based on race and gender An idea of how the function should work: the county name passed into the function should filter the data frame based on the variable Death.County; compute the necessary information from the filtered data frame; return the results in a list and in the format you see below Include a check at the begining of your function that will give an error to the user if a county is entered that is not in Connecticut county . summary (df opiod, county = "LITCHFIELD") - stotal.deaths [1 187 $mean.age [1] 40.1016 $median.age [1 41 $demographics Female Male 1 Asian, Other Black Hispanic, White White 53 128 county.summary (opiod, "HARTFORD

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!