Skip to content

Commit

Permalink
add required stuff around vignettes via usethis
Browse files Browse the repository at this point in the history
  • Loading branch information
rbe4dtad committed Jul 19, 2023
1 parent 1fe5e17 commit 6a46908
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
.github
database
companion_scripts
cran-comments.md
cran-comments.md
1 change: 1 addition & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ RUN apt update \
libgdal-dev \
libudunits2-dev \
cmake \
pandoc \
&& :

# install dev dependencies
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ vignettes/*.pdf

# R Environment Variables
.Renviron
inst/doc
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ Imports:
rappdirs,
doParallel
Suggests:
knitr,
rmarkdown,
testthat (>= 3.0.0)
Config/testthat/edition: 3
VignetteBuilder: knitr
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# InvertR
# InvTraitR (0.0.0.1)

* Added a `NEWS.md` file to track changes to the package.
2 changes: 2 additions & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.html
*.R
23 changes: 17 additions & 6 deletions vignettes/InvTraitR_vignette.Rmd
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
---
title: "Dry biomass of freshwater invertebrates using InvTraitR"
author: "James Hagan"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
author: "James Hagan"
vignette: >
%\VignetteIndexEntry{Dry biomass of freshwater invertebrates using InvTraitR}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```

```{r setup}
library(InvTraitR)
```

To see how we can use *InvTraitR* to obtain estimates of the dry biomass of freshwater invertebrates using taxon names and geographical coordinates, we will start by loading some relevant packages and some test data. The test data consist of a set of 89 invertebrate taxa collected in freshwater rockpools on six rocky outcrops (often called inselbergs) in five countries.

In addition, the data consist of latitude-longitude coordinates for the samples as well as measured body lengths for all the taxa (some body lenghts were compiled from the literature)
Expand Down Expand Up @@ -53,14 +67,13 @@ length(unique(dol_df$country_code_XXX))
# check the summary statistics
summary(dol_df)
```

We want to use the body length data to estimate the dry biomass for each of these samples using length-dry biomass allometric equations. The *InvTraitR* package houses a database of more than 350 length-dry biomass allometric equations that represent most major groups of freshwater invertebrates globally. We can use *InvTraitR* to search this database for appropriate length-dry biomass equations for the samples in our test data (`dol_df`).

To do this, we have two options both of which rely on the `get_trait_from_taxon()` function. This function (see below) takes a data.frame with at least five columns. These columns are the taxon name for which dry biomass data are required, the life stage of the taxon, the latitude and longitude coordinates from which the taxon was sampled and body size of the taxon:

```r
```{r}
get_trait_from_taxon(
data, # data.frame with at least five columns: target taxon, life stage, latitude (dd), longitude (dd) and body size (mm) if trait == "equation"
target_taxon, # character string with the column name containing the taxon names
Expand Down Expand Up @@ -115,5 +128,3 @@ print(dol_df[1,])
print(dplyr::filter(dol_df_equ$data, row == 1))
```


0 comments on commit 6a46908

Please sign in to comment.