I am struggling with Question 2 of Lab 9. I have an answer of 30.2 percent of the crashes over the past few years have resulted in an injury or a fatality, but I did not get that answer fully using dplyr functions. I just used a calculator. I was able to get the total number of incidents, and the total number of incidents with injuries or fatalities, but now I cannot figure out how to divide those two for a percentage. Any ideas? Here's my code so far:
totalcrasheswith.injuriesorfatalities <-
dat %>%
count( (Totalinjuries > 0 | Totalfatalities > 0 ) )
number.of.incidents <-
dat %>%
group_by(Incidentid) %>%
summarise( count=n())
dat %>%
WHAT'S THE FUNCTION HERE( AND HERE = totalcrasheswith.injuriesorfatalities / number.of.incidents )
I am struggling with Question 2 of Lab 9. I have an answer of 30.2 percent of the crashes over the past few years have resulted in an injury or a fatality, but I did not get that answer fully using dplyr functions. I just used a calculator. I was able to get the total number of incidents, and the total number of incidents with injuries or fatalities, but now I cannot figure out how to divide those two for a percentage. Any ideas? Here's my code so far:
Thanks, all.