-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
executable file
·116 lines (79 loc) · 3.24 KB
/
README.Rmd
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
output:
md_document:
variant: markdown_github
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
```{r include=FALSE}
knitr::opts_chunk$set(warning=FALSE, comment=NA)
```
[![Build Status](https://travis-ci.org/GBIF-Europe/darwinator.svg?branch=master)](https://travis-ci.org/GBIF-Europe/darwinator)
## Introduction
`darwinator` is an R package that can download sampling event datasets published at GBIF.org from IPT installations.
## Installing from github
If you want to install the latest version of the `darwinator` package from github, you can do it like so:
```{r message=FALSE, warning=FALSE, results="hide", eval=FALSE}
# First make sure you have the devtools package
# which simplifies installations from github
# Note: Windows users have to first install Rtools to use devtools
install.packages("devtools")
devtools::install_github("GBIF-Europe/darwinator")
# install a specific released version:
# devtools::install_github("GBIF-Europe/[email protected]")
```
## Quick start
To see some quick usage examples to get you started, open the Vignette.
Load the package in your R environment:
```{r message=FALSE, warning=FALSE, results="hide", eval=FALSE}
library(darwinator)
sed <- sampling_event_data("78360224-5493-45fd-a9a0-c336557f09c3")
df <- sed$data
dwca <- sed$dwca
citation <- sed$meta$citation
```
The package bundles a dataset with recommended Darwin Core terms. The labels for the Darwin Core terms can for example be used for validating column names in sampling event datasets. The terms data can be accessed like so:
```{r message=FALSE, warning=FALSE, results="hide", eval=FALSE}
library(darwinator)
dwc_terms
# read documentation for the dataset
?dwc_terms
```
Another example - get all GBIF dataset identifiers for Norwegian sampling event based datasets using `rgbif`. Then download all sampling event data from Norway saving it locally to enable off-line work.
```{r message=FALSE, warning=FALSE, results="hide", eval=FALSE}
library(tidyverse)
library(rgbif)
library(darwinator)
# make a search for all Norwegian sampling event dataset identfiers
search <-
dataset_search(
type = "SAMPLING_EVENT",
publishingCountry = "NO"
)
keys <- search$data$datasetKey
# use dplyr::possibly to wrap the sampling_event_data function
# so that it returns NULL if it fails on a particular dataset
library(purrr)
psed <- possibly(function(key) sampling_event_data(key), NULL)
norway <- map(keys, psed)
# exclude failed requests
fails <- unlist(map(norway, is.null))
failed_keys <- keys[fails]
successful_downloads <- norway[!fails]
# save all successful downloads
saveRDS(dl_success, "norway-sed.Rds")
# a report of parsing issues can be generated like this:
parsing_issues <- map_df(successful_downloads, c("dwca", "parsing_issues"))
readr::write_excel_csv(issues_norway, "issues-norway.csv")
```
For more usage examples, please see the vignette.
## Meta
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.
* Please [report any issues or bugs](https://github.com/GBIF-Europe/darwinator/issues).
* License: AGPL