library(biosysR)

Setup

The BioSys API is only accessible with basicauth using a valid Biosys username and password.

All biosysR functions calling the BioSys API expect optional parameters un and pw, which default to environment variables BIOSYS_UN and BIOSYS_UN, respectively. Calling biosysR functions with invalid or empty, credentials, or defaulting to non existing BIOSYS_UN and BIOSYS_PW will fail with an informative error message prompting for correct authentication.

There are three ways to supply these authentication credentials to biosysR functions.

Permanent authentication

To set-and-forget BioSys authentication, add to your ~/.Rprofile:

Sys.setenv(BIOSYS_UN = "USERNAME")
Sys.setenv(BIOSYS_PW = "PASSWORD")

Every new R session will already contain these variables.

Session authentication

To authenticate one session, export BIOSYS_UN/PW as environment variables:

Sys.setenv(BIOSYS_UN = "USERNAME")
Sys.setenv(BIOSYS_PW = "PASSWORD")

Restarting the R session will clear these variables.

Per request authentication

Supply the variables to each biosysR function:

projects <- biosys_projects(un="USERNAME", pw="PASSWORD")

Doing so will hand un and pw to biosys_get, which builds the authentication headers and uses them in the request to BioSys.

Data flow

Accessing data from BioSys

Helper functions

BioSys projects

projects <- biosys_projects()
dplyr::glimpse(projects)
DT::datatable(projects)

BioSys datasets

datasets <- biosys_datasets(project_id = 6)
dplyr::glimpse(datasets)
listviewer::jsonedit(datasets$data_package)
DT::datatable(datasets)

BioSys records

records <- biosys_records(project_id = 6)
DT::datatable(head(records, n = 100))

Example data

The example data in this project were produced by saving one project's project metadata, dataset metadata, and a subset of records to the data/ folder.

projects <- biosys_projects()[6,]
datasets <- biosys_datasets(project_id = 6)[1,]
records <- biosys_records(project_id = 6) %>% head(n = 100)
devtools::use_data(projects, datasets, records)


parksandwildlife/biosysR documentation built on May 15, 2019, 5:50 p.m.