Skip to contents

Fetches and parses the publisher's changelog, which records when a force re-supplied months ("data refresh") or failed to supply a month ("not provided"). lamp_coverage() and lamp_panel() use it to mark force-months as refreshed and to annotate gaps. The page is fetched once and cached; pass refresh = TRUE to fetch it again.

Usage

lamp_changelog(refresh = FALSE, dir = lamp_cache_dir())

Arguments

refresh

Fetch the page again even if a cached copy exists.

dir

Cache directory; see lamp_cache_dir().

Value

A tibble with columns entry_month (the changelog heading, a Date), force_name, force_id, file_type (street, outcomes, stop-and-search, a semicolon-separated combination, or all), action (refresh or not_provided), from, to (Dates, NA when the entry covers all months) and text (the entry as published). Entries that do not follow the refresh or gap patterns are kept with action = NA.

Examples

# \donttest{
# Needs network access. The page is cached in a temporary directory, and
# the example prints a message instead of failing when offline.
cl <- tryCatch(
  lamp_changelog(dir = tempfile("streetlamp-")),
  streetlamp_error_network = function(e) message(conditionMessage(e))
)
#> Network access is disabled by `STREETLAMP_OFFLINE`.
#> ℹ Could not fetch https://data.police.uk/changelog/.
if (!is.null(cl)) cl[cl$force_id == "west-yorkshire", ]
# }