Returns a register as it was at a given time, with no history and no future.

Use rr_records() for snapshots of specifically a register's schema or its data, but without adjusting the data to the schema of the same time.

rr_snapshot(register, sequence = c("entry-number", "timestamp"),
  maximum = NULL, include_maximum = TRUE, parse_datetimes = FALSE)

Arguments

register

An object of class register, returned by rr_register().

sequence

One of "entry-number" (default) or "timestamp". The snapshot is taken at the maximum value of this field of register$entries.

maximum

An integer if sequence is "entry-number" orPOSIXctifsequenceis"timestamp", giving the time at which to take the snapshot. Only the latest entry up to this value will be kept, perkey`. By default it is the maximum of all entries, to return the most recent state of the register.

include_maximum

Logical, whether to include entries whose entry-number or timestamp equals maximum.

parse_datetimes

Logical, whether to parse ISO8601 strings as datetimes with parsedate::parse_iso_8601(), otherwise leave as a string. Partial datetimes are parsed as the earliest possible datetime, e.g. "2018" becomes "2018-01-01 UTC".

Value

A tibble of records (latest entry per key).

Details

A record is the latest entry for a given key. 'Latest' can be either the maximum entry-number (recommended), or the maximum timestamp. An entry timestamp may be NA, and may not be unique. If the timestamp of any entry of a given key is NA, then no record for that key will be returned. If the timestamp is not unique, then the entry with the maximum entry-number will be chosen.

Examples

country <- rr_register("country") snapshot <- rr_snapshot(country) nrow(country$data)
#> [1] 207
nrow(snapshot$data)
#> [1] 199
country$schema$custodian
#> # A tibble: 2 x 6 #> `entry-number` type key timestamp hash custodian #> <int> <chr> <chr> <dttm> <chr> <chr> #> 1 2 system custodian 2017-07-17 10:59:47 6bdb76b1cdec0f… Tony Wor… #> 2 12 system custodian 2017-11-02 11:18:00 aa98858fc2a8a9… David de…
snapshot$schema$custodian
#> # A tibble: 1 x 6 #> `entry-number` type key timestamp hash custodian #> <int> <chr> <chr> <dttm> <chr> <chr> #> 1 12 system custodian 2017-11-02 11:18:00 aa98858fc2a8a9… David de…