gbif_citation: Get citation for datasets used

Description Usage Arguments Details Value Examples

View source: R/gbif_citation.R

Description

Get citation for datasets used

Usage

1

Arguments

x

(character) Result of call to occ_search(), occ_data(), occ_download_get(), occ_download_meta(), a dataset key, or occurrence key (character or numeric)

Details

Returns a set of citations, one for each dataset. We pull out unique dataset keys and get citations, so the length of citations may not be equal to the number of records you pass in.

Currently, this function gives back citations at the dataset level, not at the individual occurrence level. If occurrence keys are passed in, then we track down the dataset the key is from, and get the citation for the dataset.

Value

list with S3 class assigned, used by a print method to pretty print citation information. Though you can unclass the output or just index to the named items as needed.

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
55
56
57
## Not run: 
res1 <- occ_search(taxonKey=9206251, limit=2)
(xx <- gbif_citation(res1))

# each individual citation object is a list
## rights and/or citation may be NULL
xx[[1]]
xx[[1]]$rights
xx[[1]]$citation
xx[[1]]$citation$title
xx[[1]]$citation$text
xx[[1]]$citation$accessed
xx[[1]]$citation$citation

## access many citations
unlist(lapply(xx, "[[", c("citation", "citation")))

res2 <- occ_search(datasetKey='7b5d6a48-f762-11e1-a439-00145eb45e9a',
limit=20)
(xx <- gbif_citation(res2))

# if no datasetKey field included, we attempt to identify the dataset
## key field included - still works
res3 <- occ_search(taxonKey=9206251, fields=c('name','basisOfRecord','key'),
  limit=20)
(xx <- gbif_citation(res3))
## key field not included - errors
# res3 <- occ_search(taxonKey=9206251, fields=c('name','basisOfRecord','
#    protocol'), limit=20)
# (xx <- gbif_citation(res3))

# occ_data
res1 <- occ_data(taxonKey=9206251, limit=2)
(xx <- gbif_citation(res1))

# character class inputs
## pass in a dataset key
gbif_citation(x='0ec3229f-2b53-484e-817a-de8ceb1fce2b')
## pass in an occurrence key
# gbif_citation(x='1101144669')

# pass in an occurrence key as a numeric (won't work for a dataset key)
# gbif_citation(x=1101144669)

# Downloads
## occ_download_get()
# d1 <- occ_download(pred("country", "BG"), pred_gte("year", 2020))
# occ_download_meta(d1) # wait until status = succeeded
# d1 <- occ_download_get(d1, overwrite = TRUE)
# gbif_citation(d1)

## occ_download_meta()
# key <- "0000122-171020152545675"
# res <- occ_download_meta(key)
# gbif_citation(res)

## End(Not run)

rgbif documentation built on June 2, 2021, 9:07 a.m.