Steps in full cohort

# average steps by age and sex (14yo_females_steps etc)
dat_full_steps_split_sex <- dat_full %>%
  group_by(age_years, sex) %>%
  summarize(steps = mean(ad_step_count_sum_0_24hr, na.rm = TRUE), .groups = "drop") 

# no smoothening
dat_full_steps_split_sex_unsmooth <- dat_full_steps_split_sex %>%
  group_by(sex) 

# line with facets by sex -- smoothed line with real data points
ggplot(dat_full_steps_split_sex_unsmooth, aes(x = age_years, y = steps)) +
  geom_point(data = dat_full, aes(x = age_years, y = ad_step_count_sum_0_24hr), color = "#7859645D", size = 1) +
  geom_smooth(method = "loess", span = 0.99, color = "#785964", fill = "#78596433", linewidth = 1.5) + 
  labs(y = "Average Daily Steps", x = "Age") +
  facet_wrap(~ sex, labeller = as_labeller(c("male" = "Men", "female" = "Women"))) +  
  scale_y_continuous(labels = function(x) format_thousands(x)) 
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 2 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 195 rows containing missing values or values outside the scale range
## (`geom_point()`).