cc_data_fetch: Download CCAFS data

View source: R/cc_data_fetch.R

cc_data_fetchR Documentation

Download CCAFS data

Description

Download CCAFS data

Usage

cc_data_fetch(key, overwrite = FALSE, ...)

Arguments

key

(character) a character string specifying a S3 key or a URL (the output from a call to cc_search(). the key can have spaces and newlines, which are removed internally - this allows keys to break across lines as keys can be very long

overwrite

(logical) Whether to overwrite files if they already exist on your machine. Default: FALSE

...

Curl options passed on to crul::verb-GET

Details

Note that data is not read into R as data can be very large. See cc_data_read()

Look in rappdirs::user_cache_dir("ccafs") for what files are cached and to delete any.

Note that we've made it so that you can index into the return object, getting either one or many results and the S3 class will be retained, so that you can pass the result down to cc_data_read()

Value

A character vector of full file paths. A print method makes a tidy return object in an S3 class.

Examples

## Not run: 
key <- "ccafs/ccafs-climate/data/ipcc_5ar_ciat_downscaled/rcp2_6/
 2030s/bcc_csm1_1_m/10min/
 bcc_csm1_1_m_rcp2_6_2030s_prec_10min_r1i1p1_no_tile_asc.zip"

(res <- cc_data_fetch(key = key))
# indexing maintains class for easier subsetting
res[1]
res[[1]]
res[1:2]

res <- cc_list_keys()
zips <- grep("\\.zip", res$Key, value = TRUE)
x <- cc_data_fetch(zips[1])
unclass(x)
cc_data_read(x[1])
cc_data_read(x[1:3])
cc_data_read(x)

library(raster)
plot(cc_data_read(x[1]))
plot(cc_data_read(x[1:3]))

## End(Not run)

ropensci/ccafs documentation built on May 18, 2022, 9:49 a.m.