swirldev / The_R_Programming_Environment

34 stars 58 forks source link

titanic_4 not working #10

Open Darthpathos opened 4 years ago

Darthpathos commented 4 years ago

Good day Further to others that have posted here, I am working on the titanic dataset problem #4 and am having the same issue, where the answer I have (from the titanic_4_corrected file here) is not being marked as Correct.

This is the code I am running:

titanic_4 <- titanic %>% 
    select(Survived, Pclass, Age, Sex) %>%
    filter(!is.na(Age)) %>%
    mutate(agecat = cut(Age, breaks = c(0, 14.99, 50, 150), 
                        include.lowest = TRUE,
    labels = c("Under 15", "15 to 50", "Over 50"))) %>%
    group_by(Pclass, agecat, Sex) %>%
    summarize(N = n(),
        survivors = sum(Survived == 1),
        perc_survived = 100 * survivors / N)

which I realized doesn't have the head(titanic_4) line at the end; however, I'm still not able to get it working and am completely stumped. Any ideas would be appreciated. Chris