rp.datalink: Links for datasets

View source: R/rp_datalink.R

rp.datalinkR Documentation

Description

Links to specific remote datasets are provided. These can be read from the source locations or downloaded to a local directory for convenience.

Usage

  rp.datalink(name, action = "retrieve filename")
  

Arguments

name

When action = "set local directory", this should be a single character string giving the location of the local directory to be used for downloading datasets. When action = "download", this should be a character vector of dataset names for downloading to the local directory. The special case name = "all" will download all datasets. When action = "retrieve filename", this should be a single character string giving the name of the dataset whose location is required.

action

a character string taking the values "set local directory", "download" or "retrieve filename". The actions performed by these settings are indicated in the description of the name argument above.

Details

Calling the function with no arguments, as rp.datalink(), will print the dataset names, the file extensions and the remote link.

When action = "retrieve filename" but the file has not been downloaded to a local directory, the file is downloaded to a temporary file and the name of this temporary file is returned.

The specification of the local directory can be removed by setting the name argument to NULL.

The file associated with 'name' can be a zip file, in which case the unz function can be used to locate the specific file of interest. The Examples below illustrate this. Some functions to read data require a specific path to the file of interest, rather than a connection. In this case, the unzip function can be used to unzip the files to a temporary (using tempdir) or other specified directory first.

Value

If the function is called with no arguments, the dataset names, the file extensions and the remote link re returned in a dataframe. If action = "set local directory", the name of the local directory is returned. When action = "download", the names of the local files created are returned. When action = "retrieve filename", the location of the specified dataset is returned.

Examples

## Not run: 
  rp.datalink()
  rp.datalink("~/Desktop/temp", "set local directory")
  rp.datalink("global_temperature")
  
  # Reading from a file within a zip file
  zfile   <- rp.datalink("children_services")
  dirname <- "Data and Code CSRR Strand 3 - August 2023 Update"
  path <- unz(zfile, paste(dirname, "Example_Indicator_CSR.csv", sep = "/"))
  if (!requireNamespace("readr", quietly = TRUE)) 
    indicator <- read_csv(path, skip = 6, col_names = c("LA", 2011:2021))
  
## End(Not run)

rpanel documentation built on March 12, 2026, 9:07 a.m.

Related to rp.datalink in rpanel...