Question
Please use R to answer the following questions, What is the *proportion* of counties in each state that has had zero deaths? In other words:
Please use R to answer the following questions,
- What is the *proportion* of counties in each state that has had zero deaths? In other words: in each state, how many counties have had 0 deaths (divided by the total number of counties in the state)? You should produce a *data frame* with columns `state` (containing the statename) and `proportion` (containing the ratio as a decimal), saving that data frame in a variable `proportion_no_deaths_df`. Note: work through it in steps.
- What proportion of counties in Washington state has had zero deaths? Use your `proportion_no_deaths` data frame, and save your result in `wa_prop_no_deaths`.
data source:
https://github.com/nytimes/covid-19-data/
Please load (us-counties.csv) data set from above website and create data frame
or
county_df <- read.csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv")
county_df <- unite(county_df, col="county_state", county, state, sep=",", remove = FALSE) # create new column that store a string of the county and state names together
`tidyverse` package
Addition notes:
you can use the `group_by()` function to perform the same computation simultaneously across groups of rows. Your variables may need to include the specific column or value being asked for (use `pull()`).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started