Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/data-mermaid/mermaidr

R package for accessing MERMAID authenticated API endpoints
https://github.com/data-mermaid/mermaidr

Last synced: about 2 months ago
JSON representation

R package for accessing MERMAID authenticated API endpoints

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
message = FALSE,
cache = FALSE
)

options(tibble.max_extra_cols = 20)
```
# mermaidr

[![R build status](https://github.com/data-mermaid/mermaidr/workflows/R-CMD-check/badge.svg)](https://github.com/data-mermaid/mermaidr/actions)

`mermaidr` is an R package that enables you to access data from [MERMAID](https://datamermaid.org/), an open-source data platform developed to help you collect, analyze, and share coral reef monitoring data. Through `mermaidr` you can access data from [MERMAID](https://collect.datamermaid.org/) directly in R.

For more information and detailed instructions on usage, please visit the [package website](https://data-mermaid.github.io/mermaidr/).

If you are new to the R programming language, our [new R users guide](https://data-mermaid.github.io/mermaidr/articles/new_to_r.html) is a great place to start! If you find yourself stuck, please don't hesitate to [ask for help](https://data-mermaid.github.io/mermaidr/articles/getting_help.html).

## Installation

You can install mermaidr from GitHub with:

``` r
# install.packages("remotes")
remotes::install_github("data-mermaid/mermaidr")
```

## Usage

Through `mermaidr`, you can access aggregated data from your coral reef surveys. To do this, first load the package and access your MERMAID projects:

```{r}
library(mermaidr)

projects <- mermaid_get_my_projects()
```

At this point, you will have to authenticate to the Collect app. R will help you do this automatically by opening a browser window for you to log in to Collect, either via Google sign-in or username and password - however you normally do! Once you've logged in, come back to R. Your login credentials will be stored for a day, until they expire, and you will need to log in again. The package handles the expiration for you, so just log in again when prompted.

This function gives us information on your projects, including project countries, the number of sites, tags, data policies, and more:

```{r}
projects
```

To focus on just one or a few projects, you can filter by fields like the project name, country, or tags using the `dplyr` package. For example, I'll narrow in on the WCS Mozambique Coral Reef Monitoring project.

```{r}
library(dplyr)

wcs_mozambique <- projects %>%
filter(name == "WCS Mozambique Coral Reef Monitoring")
```

You can access data collected on fishbelt, benthic LIT, benthic PIT, bleaching, or habitat complexity - the main function to pull data related to your project is `mermaid_get_project_data()`:

```{r}
wcs_mozambique_fishbelt_samples <- wcs_mozambique %>%
mermaid_get_project_data(method = "fishbelt", data = "sampleevents")
```

The `data = "sampleevents"` argument specifies that I'd like to pull data summarised to the level of a sample **event**, which is a site and date - we can see that this pulls information about the site and date of samples, along with aggregations like the total biomass of that site/date, and broken down by trophic group and fish family.

```{r}
wcs_mozambique_fishbelt_samples
```

If you'd like data related to the **units** of survey (for example, to transects or quadrats), it's just a matter of changing `data` to "sampleunits":

```{r}
wcs_mozambique %>%
mermaid_get_project_data(method = "fishbelt", data = "sampleunits")
```

And raw observations are available by changing it to "observations":

```{r}
wcs_mozambique %>%
mermaid_get_project_data(method = "fishbelt", data = "observations")
```

For more details on accessing project data, please see the [Accessing Project Data](https://data-mermaid.github.io/mermaidr/articles/articles/detailed_usage.html) article.

You may also want to access data that is not related to projects. To access this data, you do not need to authenticate R with MERMAID.

For example, you can pull reference data (the names and information of the fish and benthic attributes you can choose in MERMAID), using `mermaid_get_reference()`:

```{r}
mermaid_get_reference(reference = "fishfamilies")
```

Using this function, you can access the fish family, fish genera, fish species, and benthic attributes references by changing the `reference` argument.

You can also get a list of *all* projects (not just your own):

```{r}
mermaid_get_projects()
```

As well as all sites:

```{r}
mermaid_get_sites()
```

And all managements:

```{r}
mermaid_get_managements()
```

There is additional data available from the MERMAID API, both related to specific projects and not. If you think you'll need to use these, please see `mermaid_get_endpoint()` and `mermaid_get_project_endpoint()`.

This is a small sample of the wealth of data that's available on your MERMAID projects, and on the ecosystem as a whole! Please explore the [package website](https://data-mermaid.github.io/mermaidr/) for more.