diff --git a/.github/workflows/R-CMD-CHECK.yaml b/.github/workflows/R-CMD-CHECK.yaml new file mode 100644 index 0000000..2849988 --- /dev/null +++ b/.github/workflows/R-CMD-CHECK.yaml @@ -0,0 +1,44 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: windows-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + R_KEEP_PKG_SOURCE: yes + PKG_SYSREQS: false + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: | + any::rcmdcheck + any::testthat + any::devtools + needs: check + + - name: Install package + run: devtools::install() + shell: Rscript {0} + + - name: Test coverage + run: covr::codecov(quiet = FALSE) + shell: Rscript {0} + + - uses: r-lib/actions/check-r-package@v2 + with: + error-on: '"error"' diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 3c908d3..bfc9f4d 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -1,48 +1,49 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: - - main - - master + branches: [main, master] + pull_request: + release: + types: [published] + workflow_dispatch: -name: pkgdown +name: pkgdown.yaml + +permissions: read-all jobs: pkgdown: - runs-on: macOS-latest + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-r@v1 + - uses: actions/checkout@v4 - - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true - - name: Cache R packages - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - install.packages("pkgdown", type = "binary") - shell: Rscript {0} + extra-packages: any::pkgdown, local::. + needs: website - - name: Install package - run: R CMD INSTALL . + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} - - name: Deploy package - run: | - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" - Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.5.0 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3d3dd07..0000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r - -language: R -cache: packages - -addons: - apt: - packages: - - libgit2-dev diff --git a/DESCRIPTION b/DESCRIPTION index 4561ee3..1a1bf06 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -34,12 +34,15 @@ Suggests: testthat (>= 2.1.0), knitr, rmarkdown, + ggplot2, + grid, + tools, + usethis, + covr URL: https://casaultb.github.io/azmpdata, https://github.com/casaultb/azmpdata BugReports: https://github.com/casaultb/azmpdata/issues Imports: dplyr, - ggplot2, - grid, leaflet, lubridate, magrittr, @@ -51,9 +54,7 @@ Imports: stringr, tidyr, tibble, - tools, utils, - usethis Depends: R (>= 3.5) VignetteBuilder: knitr diff --git a/R/zzz.R b/R/zzz.R index f818a7d..822cb1c 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -2,9 +2,9 @@ utils::globalVariables(c('year', 'value', 'month', 'day', 'year_dec', 'xmin', 'xmax', 'ymin', 'ymax', '.', 'ls_data', 'variable', 'tmp_variable', 'keyword', 'dataframe')) .onAttach <- function(libname, pkgname) { - # check if updates are available + # Check if updates are available update_check(gitPkg = 'casaultb/azmpdata') - message("\tazmpdata:: Indexing all available monthly azmpdata...") - assign("azmpMonthlyParams", area_indexer(doMonths=T, doParameters = T), envir = .GlobalEnv) + packageStartupMessage("\tazmpdata:: Indexing all available monthly azmpdata...") + assign("azmpMonthlyParams", area_indexer(doMonths = TRUE, doParameters = TRUE), envir = .GlobalEnv) } diff --git a/README.Rmd b/README.Rmd index 77e40be..b2f6fb1 100644 --- a/README.Rmd +++ b/README.Rmd @@ -16,7 +16,8 @@ knitr::opts_chunk$set( # *azmpdata* -[![Travis build status](https://travis-ci.org/casaultb/azmpdata.svg?branch=master)](https://travis-ci.org/casaultb/azmpdata) +[![R-CMD-check](https://github.com/casaultb/azmpdata/actions/workflows/R-CMD-CHECK.yaml/badge.svg)](https://github.com/casaultb/azmpdata/actions/workflows/R-CMD-CHECK.yaml/badge.svg) + The R package *azmpdata* provides a series of data products derived from raw data collected as part of the Atlantic Zone Monitoring Program ([AZMP](https://www.dfo-mpo.gc.ca/science/data-donnees/azmp-pmza/index-eng.html)). The data products provided in this package are used to generate the different figures contained in the Research Documents produced annually by Fisheries and Ocean Canada's Maritimes region. The Research Documents describe the physical, chemical and biological conditions observed in Maritimes region since the inception of the AZMP program (see example documents for the [physical](http://www.dfo-mpo.gc.ca/csas-sccs/Publications/ResDocs-DocRech/2018/2018_016-eng.html) conditions and for the [optical, chemical and biological](http://www.dfo-mpo.gc.ca/csas-sccs/Publications/ResDocs-DocRech/2018/2018_017-eng.html) conditions). @@ -26,8 +27,8 @@ The R package *azmpdata* provides a series of data products derived from raw dat The *azmpdata* R package can be installed from [GitHub](https://github.com) with: ``` r -# install.packages("devtools") -devtools::install_github("casaultb/azmpdata") +library(remotes) +remotes::install_github(repo = "casaultb/azmpdata", ref = "master", build_vignettes = TRUE) ``` ## Datasets diff --git a/README.md b/README.md index 89eb274..2bf5c86 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ azmpdata R package ================ Benoit Casault, Emily Chisholm -15 December, 2020 +20 February, 2026 @@ -9,8 +9,8 @@ Benoit Casault, Emily Chisholm -[![Travis build -status](https://travis-ci.org/casaultb/azmpdata.svg?branch=master)](https://travis-ci.org/casaultb/azmpdata) +[![R-CMD-check](https://github.com/casaultb/azmpdata/actions/workflows/R-CMD-CHECK.yaml/badge.svg)](https://github.com/casaultb/azmpdata/actions/workflows/R-CMD-CHECK.yaml/badge.svg) + The R package *azmpdata* provides a series of data products derived from @@ -48,33 +48,47 @@ To access a dataset in data frame format: ``` r library(azmpdata) -#> -#> casaultb/azmpdata status: -#> (Package ver: 0.2019.0.9000) Up to date -#> (Data ver:2020-11-26) is up to date +#> casaultb/azmpdata status: +#> (Package ver: 0.2019.0.9100) Up to date +#> (Data ver:2021-01-14 ) Up to date +#> azmpdata:: Indexing all available monthly azmpdata... data("Derived_Annual_Broadscale") head(Derived_Annual_Broadscale) -#> year area density_gradient_0_50 temperature_at_sea_floor -#> 1 1948 Scotion Shelf -0.00139 NA -#> 2 1949 Scotion Shelf -0.00968 NA -#> 3 1950 Scotion Shelf -0.01883 NA -#> 4 1951 Scotion Shelf -0.00092 NA -#> 5 1952 Scotion Shelf 0.00155 NA -#> 6 1953 Scotion Shelf -0.00313 NA -#> cold_intermediate_layer_volume minimum_temperature_in_cold_intermediate_layer -#> 1 -#> 2 -#> 3 -#> 4 -#> 5 -#> 6 +#> year area density_gradient_0_50 sea_temperature_0 salinity_0 +#> 1 1948 scotian_shelf_box 0.02715 6.45 31.23 +#> 2 1949 scotian_shelf_box 0.01339 8.97 31.83 +#> 3 1950 scotian_shelf_box 0.00587 8.15 31.92 +#> 4 1951 scotian_shelf_box 0.02733 9.55 31.21 +#> 5 1952 scotian_shelf_box 0.03159 8.91 31.02 +#> 6 1953 scotian_shelf_box 0.02433 8.89 31.27 +#> temperature_at_sea_floor cold_intermediate_layer_volume +#> 1 NA NA +#> 2 NA NA +#> 3 NA NA +#> 4 NA NA +#> 5 NA NA +#> 6 NA NA +#> minimum_temperature_in_cold_intermediate_layer north_atlantic_oscillation +#> 1 NA NA +#> 2 NA NA +#> 3 NA NA +#> 4 NA NA +#> 5 NA NA +#> 6 NA NA +#> sea_surface_temperature_from_satellite +#> 1 NA +#> 2 NA +#> 3 NA +#> 4 NA +#> 5 NA +#> 6 NA ``` To access a dataset in csv format: ``` r system.file("extdata/csv", "Derived_Annual_Broadscale.csv", package = "azmpdata") -#> [1] "C:/Users/ChisholmE/Documents/R/R-4.0.2/library/azmpdata/extdata/csv/Derived_Annual_Broadscale.csv" +#> [1] "C:/Users/ogradye/AppData/Local/Temp/1/RtmpWY0v01/temp_libpath305426945375/azmpdata/extdata/csv/Derived_Annual_Broadscale.csv" ``` ### Variable Organization @@ -105,18 +119,18 @@ look as below: ``` r res <- variable_lookup(keywords = c('nitrate', 'phosphate'), search_help = TRUE) -#> Joining, by = c("keyword", "variable", "dataframe") +#> Joining with `by = join_by(keyword, variable, dataframe)` head(res) -#> # A tibble: 6 x 3 +#> # A tibble: 6 × 3 #> keyword variable dataframe #> #> 1 nitrate integrated_nitrate_0_50 Derived_Annual_Sections #> 2 nitrate integrated_nitrate_0_50 Derived_Annual_Stations #> 3 nitrate integrated_nitrate_0_50 Derived_Occupations_Sections -#> 4 nitrate integrated_nitrate_50_150 Derived_Annual_Sections -#> 5 nitrate integrated_nitrate_50_150 Derived_Annual_Stations -#> 6 nitrate integrated_nitrate_50_150 Derived_Occupations_Sections +#> 4 nitrate integrated_nitrate_0_50 Derived_Occupations_Stations +#> 5 nitrate integrated_nitrate_50_150 Derived_Annual_Sections +#> 6 nitrate integrated_nitrate_50_150 Derived_Annual_Stations ``` #### Dataset Documentation diff --git a/man/azmpdata-package.Rd b/man/azmpdata-package.Rd index b06b2a5..1232224 100644 --- a/man/azmpdata-package.Rd +++ b/man/azmpdata-package.Rd @@ -2,7 +2,6 @@ % Please edit documentation in R/azmpdata-package.R \docType{package} \name{azmpdata-package} -\alias{azmpdata} \alias{azmpdata-package} \title{azmpdata: A data package to share derived metrics from AZMP research documents} \description{ diff --git a/man/azmpdata.Rd b/man/azmpdata.Rd new file mode 100644 index 0000000..930f6d3 --- /dev/null +++ b/man/azmpdata.Rd @@ -0,0 +1,65 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/azmpdata.R +\docType{package} +\name{azmpdata} +\alias{azmpdata} +\title{azmpdata: A package providing data products derived from data collected as part of +The Atlantic Zone Monitoring Program (AZMP).} +\description{ +The azmp package provides three categories of data products: +physical, biological and chemical variables. For a complete list of +variables, use library(help = "azmpdata"). +} +\section{Physical variables}{ + +The physical variables include basic oceanographic variables (temperature, salinity, +density) and additional derived variables such as parameters of the cold intermediate +layer (CIL), sea-ice parameters (area, volume, duration and timing), sea surface height +and seas surface temperature as measured by remote sensing. +} + +\section{Biological variables}{ + +The biological variables include chlorophyll, phyto- and zooplankton +abundance, and zooplankton biomass. Parameters of the spring phytoplankton bloom +as estimated from remote sensing surface chlorophyll are also included. +} + +\section{Chemical variables}{ + +The chemical variables include main nutrients (nitrate, silicate and phosphate). +Carbonate chemistry variables such as pH, dissolved inorganic carbon (DIC) and +total alkalinity (TA) are also included as annual means. +} + +\section{Other variables}{ + +Other variables of relevance for multivariate data analysis are also included. They +include air temperature, North Atlantic Oscillation (NAO) and river fresh water flux. +} + +\seealso{ +Useful links: +\itemize{ + \item \url{https://casaultb.github.io/azmpdata} + \item \url{https://github.com/casaultb/azmpdata} + \item Report bugs at \url{https://github.com/casaultb/azmpdata/issues} +} + +} +\author{ +\strong{Maintainer}: Benoit Casault \email{Benoit.Casualt@dfo-mpo.gc.ca} + +Authors: +\itemize{ + \item Emily Chisholm \email{Emily.Chisholm@dfo-mpo.gc.ca} (\href{https://orcid.org/0000-0002-1072-5879}{ORCID}) + \item Chantelle Layton \email{Chantelle.Layton@dfo-mpo.gc.ca} (\href{https://orcid.org/0000-0002-3199-5763}{ORCID}) + \item Mike McMahon \email{Mike.McMahon@dfo-mpo.gc.ca} +} + +Other contributors: +\itemize{ + \item Catherine Johnson \email{Catherine.Johnson@dfo-mpo.gc.ca} [contributor] +} + +} diff --git a/vignettes/plotting_azmpdata.Rmd b/vignettes/plotting_azmpdata.Rmd index 320a4d4..78d69c9 100644 --- a/vignettes/plotting_azmpdata.Rmd +++ b/vignettes/plotting_azmpdata.Rmd @@ -122,30 +122,32 @@ print(p) A user may also want to plot a timeseries. This method is also fairly generic and could be modified to plot any Occupations dataset. ```{r} -df_data <- get('Discrete_Occupations_Stations') # get data -variable <- 'chlorophyll' # choose variable to plot + df_data <- get('Discrete_Occupations_Stations') # get data + variable <- 'chlorophyll' # choose variable to plot + + # check for metadata + metanames <- c('year', 'month', 'day', 'area', 'section', 'station', 'date' ) + meta_df <- names(df_data)[names(df_data) %in% metanames] -# check for metadata -metanames <- c('year', 'month', 'day', 'area', 'section', 'station' ) -meta_df <- names(df_data)[names(df_data) %in% metanames] + group <- meta_df[!meta_df %in% c('year', 'month', 'day', 'date')] -group <- meta_df[!meta_df %in% c('year', 'month', 'day')] + df_data <- df_data %>% + dplyr::select(., any_of(meta_df), all_of(variable) ) %>% + dplyr::rename(., 'value' = all_of(variable) ) %>% + dplyr::rename(., 'group' = all_of(group)) #TODO some dataframes do not have groups!? -df_data <- df_data %>% - dplyr::select(., all_of(meta_df), all_of(variable) ) %>% - dplyr::rename(., 'value' = all_of(variable) ) %>% - dplyr::rename(., 'group' = all_of(group)) #TODO some dataframes do not have groups!? + # prepare data + df_data <- df_data %>% + tidyr::unite(date, year, month, day, sep="-", remove=F) %>% + dplyr::mutate(year = format(df_data$date, '%Y')) %>% + dplyr::mutate(year_dec=lubridate::decimal_date(lubridate::ymd(date))) %>% + dplyr::select(year, year_dec, value, group) -# prepare data -df_data <- df_data %>% - tidyr::unite(date, year, month, day, sep="-", remove=F) %>% - dplyr::mutate(year_dec=lubridate::decimal_date(lubridate::ymd(date))) %>% - dplyr::select(year, year_dec, value, group) # set x-axis -x_limits <- c(min(df_data$year), max(df_data$year)+1) +x_limits <- c(min(df_data$year_dec), max(df_data$year_dec)+1) x_breaks <- seq(x_limits[1]+.5, x_limits[2]-.5, by=1) x_labels <- x_breaks-.5 diff --git a/vignettes/search_azmpdata.Rmd b/vignettes/search_azmpdata.Rmd index 0bae3df..b0c03c3 100644 --- a/vignettes/search_azmpdata.Rmd +++ b/vignettes/search_azmpdata.Rmd @@ -1,9 +1,9 @@ --- -title: "azmpdata - Spatially and Temporally searching data within the azmpdata package" +title: "Spatially and Temporally searching data within the azmpdata package" author: Emily Chisholm and Jaimie Harbin output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{azmpdata - searching} + %\VignetteIndexEntry{Spatially and Temporally searching data within the azmpdata package} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- @@ -125,10 +125,12 @@ head(k) - -```{r, message=FALSE, error=FALSE, warning=FALSE, eval=FALSE, echo=FALSE, fig.cap="Figure 3: Sampling freqency per month for nitrate at station P5"} -plot_availability(areaType = "station", areaName="P5", parameters="nitrate") +For example, if a user wanted to know the frequency (ie. samples/month) for the sea surface height at Halifax, they would type in the following: + +```{r, message=TRUE, error=FALSE, warning=FALSE, eval=TRUE, fig.cap="Figure 3: Sampling freqency per month for sea_surface_height at Halifax"} +plot_availability(areaType = "station", areaName="Halifax", parameters="sea_surface_height") + ``` ## Conclusion