Skip to content

marine ecological indicator workflows and visualization, particularly for NOAA's Integrated Ecological Assessment program and the California Current region

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

noaa-iea/ecoidx

Repository files navigation

ecoidx

This R package consists of a set of helper datasets and plotting functions for developing and communicating marine ecological indicators, particularly for NOAA’s Integrated Ecological Assessment program in the California Current.

Load the R package

This package lives on Github, not yet CRAN, so you’ll need to run the following once:

remotes::install_github("marinebon/ecoidx")

Then to load the package when using:

library(ecoidx)

Datasets

Most datasets were loaded from ERDDAP searching “cciea”.

You can see the available datasets for this package from the R Console with:

data(package = "ecoidx")

Or look at the Reference.

The ERDDAP datasets are “evergreen” and preferred. These are loaded for convenience, especially for quickly trying out the data wrangling and plotting functions.

Plot

Here’s an example of using the plot_ts() function, starting with an example timeseries dataset ts1.

# example time series dataset with some NAs to show dashed line between non-NA values
head(ts1, 8)
year index Y2 SElo SEup timeseries metric type
1986 1.951787 1.951787 -0.048213 3.951787 (a) Trend and recent mean NA current.data
1987 1.631605 1.631605 -0.368395 3.631605 (a) Trend and recent mean NA current.data
1988 3.457652 3.457652 1.457652 5.457652 (a) Trend and recent mean NA current.data
1989 NA NA NA NA (a) Trend and recent mean NA current.data
1990 NA NA NA NA (a) Trend and recent mean NA current.data
1991 NA NA NA NA (a) Trend and recent mean NA current.data
1992 -1.016788 -1.016788 -3.016788 0.983212 (a) Trend and recent mean NA current.data
1993 1.526880 1.526880 -0.473120 3.526880 (a) Trend and recent mean NA current.data
# defaults to include all options
g <- plot_ts(ts1)
g

# show the caption attributed to the returned ggplot object
cat(attr(g, "caption"))
#>  The index changed by less than one standard deviation of the full time series over the last 5 years (indicated by icon: →).   The mean of the last 5 years was more than one standard deviation below the mean of the full time series (indicated by icon: +).

# without SElo or SEhi columns, just year and index
g <- plot_ts(ts1[,c("year","index")])
g

# same caption as previously, since defaults to x_recent=5 and add_avg=T
cat(attr(g, "caption"))
#>  The index changed by less than one standard deviation of the full time series over the last 5 years (indicated by icon: →).   The mean of the last 5 years was more than one standard deviation below the mean of the full time series (indicated by icon: +).

# without default x_recent, add_avg, or add_icons
g <- plot_ts(ts1, x_recent=NA, add_icons=F, add_avg=F)
g

# no caption, since missing x_recent and add_avg
cat(attr(g, "caption")) # empty caption without x_recent

Developer

This section is only meant for developers wishing to contribute or understand how this R package and website were built using devtools, usethis and pkgdown R packages.

One time

Setup Github Actions to update documentation upon git push into gh-pages branch:

usethis::use_github_action("pkgdown")

Modified the .github/workflows/pkgdown.yaml with 3 extra lines to fully document the package from source:

    - name: Install dependencies
      ...
          install.packages("devtools", type = "binary")
    - name: Deploy package
      ...
          Rscript -e 'devtools::document()'
          Rscript -e 'rmarkdown::render("README.Rmd")'

Load dataset

  1. Place into CSV into data-raw/ folder
  2. Create dataset. Create get_[dataset].R script to read, potentially wrangle and then load into R package as a dataset using usethis::use_data(). Run get_[dataset].R to generate data/[dataset].rda.
  3. Document dataset. Create R/[dataset].R. Run devtools::document() to create man/[dataset].Rd.
  4. Document package. Run pkgdown::build_reference() to update docs/reference/index.html.

Develop functions

To import a library:

usethis::use_package("dplyr")
usethis::use_package("ggplot2")

After updating documentation:

devtools::document()
pkgdown::build_reference()

About

marine ecological indicator workflows and visualization, particularly for NOAA's Integrated Ecological Assessment program and the California Current region

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages