If the data is found locally in the temporary directory then this function will load the data into R.
Otherwise if download_data = TRUE
then the data will be retrieved from the specified URL. Data can then be
saved to the temporary directory by specifying save = TRUE
.
get_data(
url = NULL,
data_trans_fn = NULL,
download_data = TRUE,
save = TRUE,
save_name = NULL,
return = TRUE,
verbose = FALSE,
use_utils = FALSE,
use_direct_download = FALSE,
retry_download = TRUE
)
Character string, indicating the url of the data to download.
Function that takes a data.table as input and returns a single dataframe of any type. If not specified defaults to transforming the data into a tibble.
Logical, defaults to TRUE
. If not found locally should the data be
downloaded from the specified URL?
Logical, should the data be saved for reuse during the current R session. Defaults to
TRUE
. If TRUE
then the data is saved to the temporary directory specified by tempdir
.
Character string, name to save the data under. Defaults to
NULL
.
Logical, should the data be returned as a dataframe.
Defaults to TRUE
.
Logical, defaults to FALSE
. Should additional status and progress messages
be displayed.
Logical, defaults to FALSE
. Used for testing alternative
data download function. When TRUE
data is downloaded using read.csv
.
Logical, defaults to FALSE
. Used for testing alternative
data download function. When TRUE
data is downloaded using download.file
.
Logical defaults to TRUE
. When TRUE
, if downloading
fails, the function will try repeatedly to download the data within 3 seconds, up
to 3 times.
The data loaded from a local copy or downloaded from the given url as a dataframe, exact format specified by data_trans_fn
get_tb_burden get_data_dict
# NOT RUN {
tb_burden <- get_data(
url = "https://extranet.who.int/tme/generateCSV.asp?ds=estimates",
save_name = "TB_burden"
)
head(tb_burden)
# }
Run the code above in your browser using DataLab