Fetches the requested modules into the cache. Before downloading anything it looks in the cache: a file that is already there and whose SHA-256 matches the catalog is reused as is.
Uso
fa_download(
survey,
year,
module = NULL,
format = "auto",
series = NULL,
cache = fa_cache(),
overwrite = FALSE,
period = NULL
)Argumentos
- survey
Short name, for example
"enaho". Seefa_surveys().- year
One year.
- module
Module codes as shown by
fa_catalog(), or their names (e.g."00_Padron"in the School Census).NULLmeans all modules of that year.- format
"auto"uses the format of the verified copy, or else the first of STATA, SPSS, CSV and DBF that the module has. Stata comes first because it is read exactly, with labels, and quickly; INEI's CSV files can have line breaks inside text answers. You can also ask for one of those formats.- series
For sources with several series, e.g.
"panel"in ENAHO.- cache
Cache folder, see
fa_cache().- overwrite
Download again even if the file is cached.
- period
For sources with several files per year, the
periodshown byfa_catalog(), e.g."Anual - (Ene-Dic)"in EPEN. A regular expression.
Valor
Invisibly, a data frame with one row per module, a status
column ("cached", "downloaded" or "changed", when the source now
serves a file that differs from the catalog), the size in bytes and
the download time in seconds (0 for cached files), of class
fa_download (see faperu-methods).
Detalles
The files that are missing are downloaded together, a few at a time
(options(faperu.connections = 4)). A transfer that breaks is retried and
resumed from where it stopped, up to options(faperu.retries = 3) times;
an unfinished file is kept as .part so the next call picks it up. Every
file is checked before it enters the cache: it must be a readable zip, not
an error page. The INEI portal only serves whole modules, so there is no
way to download single variables; download the module once and read the
columns you need with fa_read(cols = ).
