cc_data_fetch: Download CCAFS data

Description Usage Arguments Details Value Examples

View source: R/cc_data_fetch.R

Description

Download CCAFS data

Usage

1
cc_data_fetch(key, overwrite = FALSE, progress = TRUE, ...)

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

progress

(logical) Whether to print download progress. Default: TRUE

...

Curl options passed on to HttpClient

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## 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]))

# show progress
cc_cache_delete_all()
cc_data_fetch(key = key, progress = TRUE)
cc_cache_delete_all()
cc_data_fetch(key = key, progress = FALSE)

## End(Not run)

ropenscilabs/ccafs documentation built on May 26, 2018, 8:12 a.m.