inst/doc/make.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  eval = FALSE
)

## ----setup--------------------------------------------------------------------
# # install.packages("stats19")
# library(stats19)
# library(dplyr)

## -----------------------------------------------------------------------------
# # usethis::edit_r_environ() # and set STATS19_DOWNLOAD_DIRECTORY to keep the data files
# vehicles = get_stats19(type = "vehicle", year = 1979)
# range(vehicles$collision_year)
# # [1] 1979 2024
# sum(is.na(vehicles$generic_make_model)) # 0 NA values

## -----------------------------------------------------------------------------
# # Number of distinct makes and models over the years
# n_per_year = vehicles |>
#   filter(collision_year >= 1989) |>
#   group_by(collision_year) |>
#   summarise(
#     n_make_model = n_distinct(generic_make_model),
#     percent_na = round(sum(grepl("missing", generic_make_model)) / n() * 100),
#     top_5_make_model = paste(
#       names(sort(table(generic_make_model), decreasing = TRUE)[2:6]),
#       collapse = ", "
#     )
#   )
# knitr::kable(n_per_year)

Try the stats19 package in your browser

Any scripts or data that you put into this service are public.

stats19 documentation built on March 18, 2026, 5:08 p.m.