gsw_deaths |>
group_by(race) |>
summarise(
"0th Percentile" = round(quantile(age, probs = 0, na.rm = TRUE)),
"10th Percentile" = round(quantile(age, probs = 0.1, na.rm = TRUE)),
"20th Percentile" = round(quantile(age, probs = 0.2, na.rm = TRUE)),
"30th Percentile" = round(quantile(age, probs = 0.3, na.rm = TRUE)),
"40th Percentile" = round(quantile(age, probs = 0.4, na.rm = TRUE)),
"50th Percentile" = round(quantile(age, probs = 0.5, na.rm = TRUE)),
"60th Percentile" = round(quantile(age, probs = 0.6, na.rm = TRUE)),
"70th Percentile" = round(quantile(age, probs = 0.7, na.rm = TRUE)),
"80th Percentile" = round(quantile(age, probs = 0.8, na.rm = TRUE)),
"90th Percentile" = round(quantile(age, probs = 0.9, na.rm = TRUE)),
"100th Percentile" = round(quantile(age, probs = 1, na.rm = TRUE)),
) |>
pivot_longer(cols = 2:12, names_to = " ", values_to = "value") |>
pivot_wider(names_from = race, values_from = value) |>
select(
" ",
"NA, n=7" = "NA",
"Am. Indian, n=4" = "Am. Indian",
"Asian, n=33" = Asian,
"Black, n=4438" = Black,
"White, n=1742" = White,
"Other, n=45" = Other
) |>
knitr::kable()