Skip to contents

Load a data file from a source data project, or list versions of the file.

Usage

pophive_get_file(path, date = NULL, commit_hash = NULL, versions = FALSE)

Arguments

path

Path to the file.

date

Date of the version to load; A Date, or character in the format YYYY-MM-DD. Will match to the nearest version.

commit_hash

SHA signature of the committed version; can be the first 6 or so characters. Ignored if date is provided.

versions

Logical; if TRUE, will return a list of available version, rather than a

Value

If versions is TRUE, a data.frame with columns for the hash, author, date, and message of each commit. Otherwise, the path to a temporary file, if one was extracted.

Examples

path <- "../../data/wastewater/raw/flua.csv.xz"
if (file.exists(path)) {
  # list versions
  versions <- pophive_get_file(path, versions = TRUE)
  print(versions[, c("date", "hash")])

  # extract a version to a temporary file
  temp_path <- pophive_get_file(path, "2025-05")
  basename(temp_path)
}
#>                             date                                     hash
#> 1  Mon Jun 9 00:36:37 2025 +0000 d978116e3b12926798d8f573bc1d3e913d67a547
#> 2  Mon Jun 2 09:32:13 2025 +0000 784558d5a95e20f3950a36770f82a5a0fabebb21
#> 3 Tue May 27 13:56:02 2025 -0400 36914a3d9b47f91eba0b5d8dfddd357a700fd525
#> [1] "flua-d97811.csv.xz"