pg_data: Download data from Pangaea.

Description Usage Arguments Details Value Author(s) References Examples

View source: R/pg_data.R

Description

Grabs data as a dataframe or list of dataframes from a Pangaea data repository URI; see: https://www.pangaea.de/

Usage

1
2
3
4
5
pg_cache_clear(doi = NULL, prompt = TRUE)

pg_cache_list()

pg_data(doi, overwrite = TRUE, mssgs = TRUE, ...)

Arguments

doi

DOI of Pangaeae single dataset, or of a collection of datasets. Expects either just a DOI of the form 10.1594/PANGAEA.746398, or with the URL part in front, like https://doi.pangaea.de/10.1594/PANGAEA.746398

prompt

(logical) Prompt before clearing all files in cache? No prompt used when DOIs assed in. Default: TRUE

overwrite

(logical) Ovewrite a file if one is found with the same name

mssgs

(logical) print information messages. Default: TRUE

...

Curl options passed on to crul::HttpClient

Details

Data files are stored in an operating system appropriate location. Run rappdirs::user_cache_dir("pangaear") to get the storage location on your machine.

Some files/datasets require the user to be logged in. For now we just pass on these - that is, give back nothing other than metadata.

Value

One or more items of class pangaea, each with the doi, parent doi (if many dois within a parent doi), url, citation, path, and data object. Data object depends on what kind of file it is. For tabular data, we print the first 10 columns or so; for a zip file we list the files in the zip (but leave it up to the user to dig unzip and get files from the zip file); for png files, we point the user to read the file in with png::readPNG()

Author(s)

Naupaka Zimmerman, Scott Chamberlain

References

https://www.pangaea.de

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
## Not run: 
# a single file
(res <- pg_data(doi='10.1594/PANGAEA.807580'))
res[[1]]$doi
res[[1]]$citation
res[[1]]$data

# another single file
pg_data(doi='10.1594/PANGAEA.807584')

# Many files
(res <- pg_data(doi='10.1594/PANGAEA.761032'))
res[[1]]
res[[2]]

# Manipulating the cache
## list files in the cache
pg_cache_list()

## clear all data
# pg_cache_clear()
pg_cache_list()

## clear a single dataset by DOI
pg_data(doi='10.1594/PANGAEA.812093')
pg_cache_list()
pg_cache_clear(doi='10.1594/PANGAEA.812093')
pg_cache_list()

## clear more than 1 dataset by DOI
lapply(c('10.1594/PANGAEA.746398','10.1594/PANGAEA.746400'), pg_data)
pg_cache_list()
pg_cache_clear(doi=c('10.1594/PANGAEA.746398','10.1594/PANGAEA.746400'))
pg_cache_list()

# search for datasets, then pass in DOIs
(searchres <- pg_search(query = 'birds', count = 20))
pg_data(searchres$doi[1])
pg_data(searchres$doi[2])
pg_data(searchres$doi[3])
pg_data(searchres$doi[4])
pg_data(searchres$doi[7])

# png file
pg_data(doi = "10.1594/PANGAEA.825428")

# zip file
pg_data(doi = "10.1594/PANGAEA.860500")

# login required
## we skip file download
pg_data("10.1594/PANGAEA.788547")

## End(Not run)

pangaear documentation built on Jan. 4, 2018, 4:31 a.m.