diff --git a/.Rbuildignore b/.Rbuildignore index 8adea00..13959ad 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -11,4 +11,4 @@ .github database companion_scripts -cran-comments.md \ No newline at end of file +cran-comments.md diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a5728c0..af64295 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -7,6 +7,7 @@ RUN apt update \ libgdal-dev \ libudunits2-dev \ cmake \ + pandoc \ && : # install dev dependencies diff --git a/.gitignore b/.gitignore index 999926f..9236faa 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ vignettes/*.pdf # R Environment Variables .Renviron +inst/doc diff --git a/DESCRIPTION b/DESCRIPTION index 60562a1..cf73f63 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,5 +30,8 @@ Imports: rappdirs, doParallel Suggests: + knitr, + rmarkdown, testthat (>= 3.0.0) Config/testthat/edition: 3 +VignetteBuilder: knitr diff --git a/NEWS.md b/NEWS.md index 661e12c..5b1d042 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,3 @@ -# InvertR +# InvTraitR (0.0.0.1) * Added a `NEWS.md` file to track changes to the package. diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000..097b241 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/InvTraitR_vignette.Rmd b/vignettes/InvTraitR_vignette.Rmd index e5b00cd..65e3924 100644 --- a/vignettes/InvTraitR_vignette.Rmd +++ b/vignettes/InvTraitR_vignette.Rmd @@ -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) @@ -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 @@ -115,5 +128,3 @@ print(dol_df[1,]) print(dplyr::filter(dol_df_equ$data, row == 1)) ``` - -