---
title: "NSR R package"
author: "Brian Maitner"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{NSR R package}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
  
---


```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Native Species Resolver

The package `NSR` is designed to interact with the Native Species Resolver of the Botanical Information and Ecology Network.  


#Installing NSR
```{r, eval=FALSE}

library(devtools)
install_github("EnquistLab/RNSR/NSR")


```

#The easiest case: one species in one political division

```{r}
library(NSR)
NSR_simple(species = "Acer rubrum",
           country =  "Canada",
           state_province = "Ontario")


```

#Multiple species
When submitting data into the NSR, the function expects a data.frame containing 5 columns as input, however only the columns "species" and "country" (the first two) need to be populated. If you ever forget the input format, you can use the function NSR_template as a quick look-up, or to populate.

```{r}

head(NSR_template())

```

#Example data
```{r}

#First, pull the example data that are included with the package
data("nsr_testfile")
head(nsr_testfile)

example_results <- NSR(nsr_testfile)

head(example_results)

```

#Source metadata
To access metadata for the sources currently consulted by the NSR, use the function `NSR_metadata()`.  To figure out which political divisions contain checklists that were consulted by the NSR, use the function `NSR_political_divisions()`.

```{r}

sources <- NSR_metadata()

checklist_per_political_divisions <- NSR_political_divisions()

# If you'd rather see which political divisions are available within each checklist, set "by_country" to FALSE

political_divisions_per_checklist <- NSR_political_divisions(by_country = FALSE)


```


