View source: R/cto_dataset_download.R
| cto_dataset_download | R Documentation |
Downloads one or more datasets from a SurveyCTO server to a local directory as CSV files.
cto_dataset_download(id = NULL, dir = getwd(), overwrite = FALSE)
id |
A character vector of dataset IDs to download.
If |
dir |
A string specifying the directory where CSV files will be saved. Defaults to the current working directory. |
overwrite |
Logical. If |
Smart Downloading: If overwrite = FALSE, the function checks if the
target file already exists in dir and skips the download.
Error Handling: If a specific dataset fails to download, a warning is printed with the dataset name, but the function continues processing the remaining list.
(Invisibly) A character vector of file paths to the successfully
downloaded CSVs. Returns NULL if no datasets were found.
Other Dataset Management Functions:
cto_dataset_create(),
cto_dataset_delete(),
cto_dataset_info(),
cto_dataset_list()
## Not run:
# --- Example 1: Download a specific dataset ---
paths <- cto_dataset_download(id = "household_data", dir = tempdir())
df <- read.csv(paths[1])
# --- Example 2: Download all datasets, skip existing files ---
paths <- cto_dataset_download(dir = "my_data_folder", overwrite = FALSE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.