TEMPO provides access to the Romanian National Institute
of Statistics’ TEMPO Online database. It has two public functions:
tempo_toc() lists the available statistical tables and
their matrix codes.tempo_bulk() downloads one or more complete tables as
CSV files.The database is an external service, so the examples below need an internet connection. They are deliberately not evaluated when this vignette is built.
Start by retrieving the table of contents. The default language is
Romanian; set language = "en" to obtain English table
names.
The result is a data frame with name and
code columns. Search the name column to
identify a table of interest, then retain its code.
population_tables <- tables[
grepl("population", tables$name, ignore.case = TRUE),
c("name", "code")
]
head(population_tables)Use full_description = TRUE when you need the
statistical domain, sub-domain, survey name, and last-update date for
every listed table. This makes one additional request for every matrix,
so it can take a long time.
Choose an output directory that you control.
tempo_bulk() creates it if needed and writes only there.
For example, the code below downloads the ACC101B matrix in
English.
data_directory <- file.path(tempdir(), "tempo-data")
files <- tempo_bulk(
codes = "ACC101B",
language = "en",
directory = data_directory
)
filestempo_bulk() returns the paths of files it downloaded,
invisibly. A repeated call returns no path when the local file is
already current, so construct the CSV path from the output directory and
matrix code when later steps need the file. The downloaded files are
ordinary comma-separated CSV files.
Pass a character vector to download multiple matrices. Requests are made sequentially, which keeps use of the public service conservative.
codes <- c("ACC101B", "ACC101C")
files <- tempo_bulk(codes, language = "ro", directory = data_directory)Some matrices have dimensions with many selectable values.
TEMPO splits those requests into sequential chunks and
combines the resulting CSV content into one file per matrix. A complete
table can still be large, so download only the tables you need.
Before replacing a requested file, tempo_bulk() compares
its modification date with the update date published by TEMPO Online.
Repeating a download is therefore safe: files that are already current
are skipped.