The categorizations are based on https://unstats.un.org/unsd/gender/timeuse/23012019%20ICATUS.pdf
timeuse_df %>%
filter(activity == "Sleep", age < 90) %>%
group_by(person_id, age, mult) %>%
summarise(total_sleep_mins = sum(duration_mins, na.rm = TRUE),
.groups = 'drop') %>% group_by(age) %>%
summarise(avg_sleep_weighted_mins = weighted.mean(total_sleep_mins, w = mult, na.rm = TRUE)) %>%
mutate(avg_sleep_hours = avg_sleep_weighted_mins / 60) %>%
ggplot(aes(x = age, y = avg_sleep_hours)) +
geom_smooth(
method = "loess",
se = TRUE,
color = "black",
fill = "gray80"
) +
#geom_line()+
scale_y_continuous(limits = c(8, 13), breaks = seq(8, 13, by = 1)) +
scale_x_continuous(breaks = seq(0, 90, by = 10), limits = c(6, 95)) +
labs(
title = "Average Daily Sleep Declines Through Adolescence",
x = "Age",
y = "Average Sleep (hours per day)",
caption = "Source: MoSPI Time Use Survey, 2024"
) +
theme_fivethirtyeight() +
theme(
text = element_text(family = "ath"),
plot.title = element_text(
family = "ath",
face = "bold",
size = 18,
margin = margin(b = 20)
),
plot.caption = element_text(
family = "ath",
size = 10,
color = "gray50"
),
axis.title = element_text(family = "ath", size = 12),
axis.title.y = element_text(margin = margin(r = 15)),
axis.title.x = element_text(margin = margin(t = 15)),
axis.text.y = element_text(
family = "ath",
size = 12,
margin = margin(r = 8)
),
axis.text.x = element_text(
family = "ath",
size = 12,
margin = margin(t = 8)
),
panel.grid.major = element_line(linewidth = 0.5, color = "gray90"),
panel.grid.minor = element_blank()
)
## `geom_smooth()` using formula = 'y ~ x'
all_persons <- timeuse_df %>%
distinct(person_id, gender, mult)
person_activity_summary <- timeuse_df %>%
filter(!is.na(activity) & activity != "Unclassified") %>%
group_by(person_id, activity) %>%
summarise(total_duration_mins = sum(duration_mins, na.rm = TRUE), .groups = 'drop')
gender_summary <- all_persons %>%
tidyr::crossing(activity = unique(person_activity_summary$activity)) %>%
left_join(person_activity_summary, by = c("person_id", "activity")) %>%
mutate(total_duration_mins = ifelse(is.na(total_duration_mins), 0, total_duration_mins)) %>%
group_by(gender, activity) %>%
summarise(
avg_hours_per_person = weighted.mean(total_duration_mins, w = mult, na.rm = TRUE) / 60,
.groups = 'drop'
)
gender_summary_wide <- gender_summary %>%
pivot_wider(names_from = gender, values_from = avg_hours_per_person) %>%
mutate(gap = female - male) %>%
slice_max(order_by = abs(gap), n = 15) %>%
mutate(activity = fct_reorder(activity, gap))
ggplot(gender_summary_wide, aes(y = activity)) +
geom_segment(aes(x = male, xend = female), color = "gray", linewidth = 1.5, alpha = 0.5) +
geom_point(aes(x = female, color = "Female"), size = 4) +
geom_point(aes(x = male, color = "Male"), size = 4) +
theme_fivethirtyeight() +
scale_color_manual(name = "", values = c("Female" = "#0072B2", "Male" = "#D55E00")) +
labs(
title = "Unpaid Work Accounts for the Largest Gender Gap in Time Use",
subtitle = "Comparing the average daily hours for men and women",
x = "Average Hours Per Day (per person)",
y = "",
caption = "Source: MoSPI Time Use Survey, 2024"
) +
theme(
text = element_text(family = "ath"),
plot.title = element_text(family = "ath", size = 16, margin = margin(b = 10, l = -130)),
plot.subtitle = element_text(family = "ath", size = 14, margin = margin(b = 20, l = -130), color = "gray40"),
plot.caption = element_text(family = "ath", size = 10, color = "gray50", margin = margin(t = 20)),
axis.title = element_text(family = "ath", size = 12),
axis.text = element_text(family = "ath", size = 11),
plot.margin = margin(15, 50, 10, 0),
legend.position = "top",
legend.direction = "horizontal",
legend.background = element_rect(fill = "transparent"),
legend.key = element_rect(fill = "transparent", color = NA),
legend.title = element_blank(),
legend.text = element_text(size = 10, family = "ath")
)
all_persons_sector <- timeuse_df %>%
distinct(person_id, sector, mult)
person_activity_summary_sector <- timeuse_df %>%
filter(!is.na(activity) & activity != "Unclassified") %>%
group_by(person_id, activity) %>%
summarise(total_duration_mins = sum(duration_mins, na.rm = TRUE), .groups = 'drop')
sector_summary <- all_persons_sector %>%
tidyr::crossing(activity = unique(person_activity_summary_sector$activity)) %>%
left_join(person_activity_summary_sector, by = c("person_id", "activity")) %>%
mutate(total_duration_mins = ifelse(is.na(total_duration_mins), 0, total_duration_mins)) %>%
group_by(sector, activity) %>%
summarise(
avg_hours_per_person = weighted.mean(total_duration_mins, w = mult, na.rm = TRUE) / 60,
.groups = 'drop'
)
sector_summary_wide <- sector_summary %>%
pivot_wider(names_from = sector, values_from = avg_hours_per_person) %>%
mutate(gap = Urban - Rural) %>%
slice_max(order_by = abs(gap), n = 15) %>%
mutate(activity = fct_reorder(activity, gap))
ggplot(sector_summary_wide, aes(y = activity)) +
geom_segment(aes(x = Rural, xend = Urban), color = "gray", linewidth = 1.5, alpha = 0.5) +
geom_point(aes(x = Urban, color = "Urban"), size = 4) +
geom_point(aes(x = Rural, color = "Rural"), size = 4) +
theme_fivethirtyeight() +
scale_color_manual(name = "", values = c("Urban" = "#0072B2", "Rural" = "#D55E00")) +
labs(
title = "Rural-Urban Divide in Daily Time Use",
subtitle = "Comparing daily hours for the 15 activities with the largest urban-rural disparities",
x = "Average Hours Per Day (per person)",
y = "",
caption = "Source: MoSPI Time Use Survey, 2024"
) +
theme(
text = element_text(family = "ath"),
plot.title = element_text(family = "ath", size = 20, margin = margin(b = 10)),
plot.subtitle = element_text(family = "ath", size = 14, margin = margin(b = 20), color = "gray40"),
plot.caption = element_text(family = "ath", size = 10, color = "gray50", margin = margin(t = 20)),
axis.title = element_text(family = "ath", size = 12),
axis.text = element_text(family = "ath", size = 11),
plot.margin = margin(15, 15, 10, 15),
legend.position = "top",
legend.direction = "horizontal",
legend.background = element_rect(fill = "transparent"),
legend.key = element_rect(fill = "transparent", color = NA),
legend.title = element_blank(),
legend.text = element_text(size = 14, family = "ath")
)
high_level_summary <- timeuse_df %>%
filter(!is.na(activity) & activity != "Unclassified") %>%
mutate(
activity_group = case_when(
activity == "Sleep" ~ "Sleep",
activity %in% c("Eating & Drinking", "Personal Hygiene & Health", "Receiving Care") ~ "Personal Care",
activity %in% c(
"Formal Employment",
"Household Enterprise (Goods)",
"Household Enterprise (Services)",
"Work-Related Training",
"Seeking Employment",
"Setting up a Business"
) ~ "Paid Work",
activity %in% c(
"Food & Meal Management",
"Cleaning & Maintenance",
"Childcare & Instruction",
"Shopping",
"Agriculture & Fishing (Own-Use)",
"Community Volunteering",
"Direct Volunteering"
) ~ "Unpaid Work & Care",
activity %in% c("Formal Education", "Homework", "Additional Study") ~ "Learning",
# Group all leisure, social, and travel into one bucket for this high-level view
TRUE ~ "Leisure, Social & Travel"
)
)
age_group_summary <- high_level_summary %>%
mutate(age_group = cut(
age,
breaks = c(5, 14, 24, 59, Inf),
labels = c(
"Children (6-14)",
"Youth (15-24)",
"Adults (25-59)",
"Seniors (60+)"
),
right = TRUE,
include.lowest = TRUE
)) %>%
filter(!is.na(age_group)) %>%
group_by(person_id, age_group, activity_group, mult) %>%
summarise(total_duration = sum(duration_mins, na.rm = TRUE),
.groups = "drop") %>%
group_by(age_group, activity_group) %>%
summarise(avg_hours = weighted.mean(total_duration, w = mult, na.rm = TRUE) / 60,
.groups = "drop")
stacking_order <- c(
"Sleep",
"Personal Care",
"Paid Work",
"Unpaid Work & Care",
"Learning",
"Leisure, Social & Travel"
)
age_group_summary$activity_group <- factor(age_group_summary$activity_group, levels = stacking_order)
ggplot(age_group_summary,
aes(x = age_group, y = avg_hours, fill = activity_group)) +
geom_col(position = "fill", colour = "transparent") +
scale_y_continuous(labels = scales::percent) +
scale_fill_brewer(palette = "Dark2", name = "") +
labs(
title = "Share of a 24-hour day spent on major activities, by age group",
x = "",
y = "Percentage of Day",
caption = "Source: MoSPI Time Use Survey, 2024"
) +
theme_fivethirtyeight() +
theme(
text = element_text(family = "ath"),
plot.title = element_text(
family = "ath",
size = 20,
margin = margin(b = 10)
),
plot.subtitle = element_text(
family = "ath",
size = 14,
margin = margin(b = 20),
color = "gray40"
),
plot.caption = element_text(
family = "ath",
size = 10,
color = "gray50",
margin = margin(t = 20)
),
axis.title = element_text(family = "ath", size = 12),
axis.text = element_text(family = "ath", size = 11),
plot.margin = margin(15, 15, 10, 15),
legend.position = "bottom",
legend.direction = "horizontal",
legend.background = element_rect(fill = "transparent"),
legend.key = element_rect(fill = "transparent", color = NA),
legend.title = element_blank(),
legend.text = element_text(size = 14, family = "ath")
)
“children” are defined as persons under 15 years of age, and “youth” are defined as those aged 15–24.
youth_activities <- c(
"Formal Education", "Homework",
"Food & Meal Management", "Cleaning & Maintenance", "Childcare & Instruction",
"Mass Media", "Sports & Exercise", "Hobbies & Games",
"Socializing & Communication"
)
youth_summary <- timeuse_df %>%
filter(age >= 6 & age <= 24, activity %in% youth_activities, gender %in% c('male', 'female')) %>%
group_by(person_id, age, gender, activity, mult) %>%
summarise(total_duration = sum(duration_mins, na.rm = TRUE), .groups = "drop") %>%
group_by(age, gender, activity) %>%
summarise(avg_hours = weighted.mean(total_duration, w = mult, na.rm = TRUE) / 60, .groups = "drop")
ggplot(youth_summary, aes(x = age, y = avg_hours, color = gender)) +
geom_smooth(se = FALSE, size = 1.2) +
facet_wrap(~ activity, scales = "free", ncol = 3) +
scale_color_manual(name = "Gender", values = c("female" = "#0072B2", "male" = "#D55E00")) +
labs(
title = "Average daily hours spent on key activities for ages 6-24, by gender",
x = "Age (years)",
y = "Average Hours Per Day",
caption = "Source: MoSPI Time Use Survey, 2024"
) +
theme_minimal(base_family = "ath") +
theme(
plot.title = element_text(face = "bold", size = 20, margin = margin(b = 10)),
plot.subtitle = element_text(size = 14, color = "gray40", margin = margin(b = 20)),
strip.text = element_text(face = "bold", size = 11, hjust = 0),
legend.position = "top",
panel.spacing = unit(1.5, "lines")
) +
theme_fivethirtyeight() +
theme(
text = element_text(family = "ath"),
plot.title = element_text(
family = "ath",
size = 20,
margin = margin(b = 10)
),
plot.subtitle = element_text(
family = "ath",
size = 14,
margin = margin(b = 20),
color = "gray40"
),
plot.caption = element_text(
family = "ath",
size = 10,
color = "gray50",
margin = margin(t = 20)
),
axis.title = element_text(family = "ath", size = 12),
axis.text = element_text(family = "ath", size = 11),
plot.margin = margin(15, 15, 10, 15),
legend.position = "bottom",
legend.direction = "horizontal",
legend.background = element_rect(fill = "transparent"),
legend.key = element_rect(fill = "transparent", color = NA),
legend.title = element_blank(),
legend.text = element_text(size = 14, family = "ath")
)
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'