The following code reproduces the data set that was submitted for TidyTuesday.
Install the package from GitHub:
Load the package:
Choose sensors sites from webtris.nationalhighways.co.uk and store site name in vector. These sensors are on the A64 Eastbound from York to Scarborough.
sites_chosen <- c("30361466", "30361338", "30361451", "30361486")
Pull sensor site data, and find ID for chosen sites:
sites <- sites()
sites_id <- sites |>
tibble::as_tibble() |>
dplyr::filter(Description %in% sites_chosen) |>
dplyr::pull(Id)
Map over sites and extract daily report for each site for May 2021.
Note that page_size
is chosen to exceed 31 days, 4
intervals per hour over 24 hours a day.
sites_data <- purrr::map(
.x = sites_id,
.f = ~daily_report(
site = .x,
start_date = "01052021",
end_date = "31052021",
page_size = 3000
)
)
Reformat the data into a single tibble: