Session 5 : Grouping challenge
Les challenges 5.4.2 et 5.4.3 ne sont pas clair. Possibilité d'une coquille ? *** 5.4.2 > 2ème solution :**
flights %>%
mutate(
canceled = is.na(dep_time) | is.na(arr_time)
) %>%
mutate(wday = strftime(time_hour,'%A')) %>%
group_by(day) %>%
mutate(
prop_cancel_day = sum(canceled)/sum(!canceled),
av_delay = mean(dep_delay, na.rm = TRUE)
) %>%
group_by(wday) %>%
summarize(
mean_cancel_day = mean(prop_cancel_day, na.rm = TRUE),
sd_cancel_day = sd(prop_cancel_day, na.rm = TRUE),
mean_av_delay = mean(av_delay, na.rm = TRUE),
sd_av_delay = sd(av_delay, na.rm = TRUE)
) %>%
ggplot(mapping = aes(x = mean_av_delay, y = mean_cancel_day, color = wday)) +
geom_point() +
geom_errorbarh(mapping = aes(
xmin = -sd_av_delay + mean_av_delay,
xmax = sd_av_delay + mean_av_delay
)) +
geom_errorbar(mapping = aes(
ymin = -sd_cancel_day + mean_cancel_day,
ymax = sd_cancel_day + mean_cancel_day
))
a modifier avec
flights %>%
mutate(
canceled = is.na(dep_time) | is.na(arr_time)
) %>%
mutate(wday = strftime(time_hour,'%A')) %>%
group_by(wday) %>%
mutate(
prop_cancel_day = sum(canceled)/sum(!canceled),
av_delay = mean(dep_delay, na.rm = TRUE)
) %>%
summarize(
mean_cancel_day = mean(prop_cancel_day, na.rm = TRUE),
sd_cancel_day = sd(prop_cancel_day, na.rm = TRUE),
mean_av_delay = mean(av_delay, na.rm = TRUE),
sd_av_delay = sd(av_delay, na.rm = TRUE)
) %>%
ggplot(mapping = aes(x = mean_av_delay, y = mean_cancel_day, color = wday)) +
geom_point() +
geom_errorbarh(mapping = aes(
xmin = -sd_av_delay + mean_av_delay,
xmax = sd_av_delay + mean_av_delay
)) +
geom_errorbar(mapping = aes(
ymin = -sd_cancel_day + mean_cancel_day,
ymax = sd_cancel_day + mean_cancel_day
))
?
Il faudrait au moins un petit texte explicatif car ce n'est pas claire du tout.
*** 5.4.3 > 2ème solution :**
Peut on avoir le graphique attendu ? Car la solution actuelle ne permet pas d'obtenir l'information sur la destination (en plus du 'career'), ou alors il faudrait aussi un texte explicatif.
Merci d'avance ;)