Open SalvadorW2 opened 3 years ago
Am I even going about this the right way?
Besides posting to GitHub two hours before the deadline? 😄
Drop the call to select()
as it's unnecessary. Instead, replace it with filter()
with Totalinjuries
greater than zero or Totalfatalities
greater than zero.
Your mutate()
call looks good - stick with that.
Afterwards, use group_by()
on hour
and use summarize()
to find the sum of casualties
(with sum()
) divided by n()
. That should get you there.
Sorry about that.
I had tried just about everything I could think of and was wondering if anyone else was still online.
@SalvadorW2 you're totally fine! Just having fun. You did very well on the lab and I'm excited to hear that you'd like to train further in R after the course. You've got the knack to hack.
How do I add the total number of incidents and the total number of casualties in order to get the average?
dat %>% select(Incidentid, Totalinjuries, Totalfatalities, hour) %>% mutate(casualties = Totalinjuries + Totalfatalities, harmful = ifelse(casualties > 0, TRUE, FALSE)) %>% select(Incidentid, casualties) %>% group_by(Incidentid, casualties)
Am I even going about this the right way?