Open KaytieS opened 6 months ago
@KaytieS You are quite close. Use hour12, I'm not sure if there is a bug in the code, but assume all is right and submit your answers as though it is correct.
We can start simple with this:
dat %>%
count( hour12, age ) %>%
filter( hour12 == " 7 AM" ) %>%
arrange( -n ) %>%
pander()
We are counting hour12 and age, filtering for hour12 when it is 7AM, arrange -n for descending order.
If you would like to add in additional analysis with percentages:
dat %>%
group_by(hour12, age) %>%
summarize(n = n()) %>%
group_by(age) %>%
mutate(n.age = sum(n)) %>%
mutate(prop.age = (n / n.age)) %>%
filter(hour12 == " 7 AM")%>%
arrange(-n)
@JasonSills okay, that makes sense, thank you for the response!
In part 2 question 2 I can't figure out how to add the count for age and hour into the table, this is what I have so far: dat %>% group_by (hour, age) %>% filter(hour == "07") %>% summarise(n = n()) %>% mutate(p = n / sum(n)) %>% pander()
And I know that by using dat%>%count(age) I can get the values for n.age but when I try to to add this into the table it returns 1 for all of the values and it gives me an error if I try to create the variable using count in mutate. I also noticed that although the question says to use the variable hour12, the data in the example table comes from using the variable hour, does it matter which one you use? Sorry just realized I didn't tag you @JasonSills