Open BissKuttner opened 5 years ago
These are actually easier using simple logical statements. Recall that if we can use a logical statement to specify the group we want, then we can easily count group members and find the proportion of the total:
sum( dat$gender == "male" ) # total number of males in the study
mean( dat$gender == "male" ) # proportion of study group that is male
That makes sense. What confuses me is that the question is asking for "each week." If I take that mean, am I getting the answer for each week or the mean of the total of Mondays?
I think I have it.
You are right, it's a little ambiguous.
If you calculate the proportion for each week of the year, you would need to group by week, something like:
dat %>%
group_by( week ) %>%
summarize( ave.on.mondays = mean( day == "Mon" ) )
I cant figure this out. I have created a variable to get a count for accidents on Mondays I thought I had generated avg accidents per week I dont know how to combine these two. Nothing I do seems to work.
TO GET TO ACCIDENTS ON MONDAYS
TO GET AVERAGE CRASHES PER WEEK