diff --git a/.github/workflows/R-CMD-check-latest.yaml b/.github/workflows/R-CMD-check-latest.yaml index a719084..f40a86b 100644 --- a/.github/workflows/R-CMD-check-latest.yaml +++ b/.github/workflows/R-CMD-check-latest.yaml @@ -23,10 +23,8 @@ jobs: fail-fast: false matrix: config: - - {os: ubuntu-20.04, r: 'release'} - - {os: ubuntu-20.04, r: 'devel'} - - {os: ubuntu-18.04, r: 'release'} - - {os: ubuntu-18.04, r: 'devel'} + # - {os: ubuntu-22.04, r: 'release'} + # - {os: ubuntu-22.04, r: 'devel'} - {os: windows-latest, r: 'release'} - {os: macOS-latest, r: 'release'} @@ -35,13 +33,15 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} - - - uses: r-lib/actions/setup-pandoc@v1 + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: false - name: Query dependencies run: | @@ -89,7 +89,7 @@ jobs: - name: Upload check results if: failure() - uses: actions/upload-artifact@main + uses: actions/upload-artifact@v3 with: name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results path: check diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 5c5bf3e..e2f576b 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -2,6 +2,8 @@ # https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions on: push: + branches: + - '*' name: R-CMD-check @@ -15,71 +17,30 @@ jobs: fail-fast: false matrix: config: - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-22.04, r: 'release'} - {os: windows-latest, r: 'release'} - - {os: macOS-latest, r: 'release'} + - {os: macOS-latest, r: 'release'} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - RSPM: ${{ matrix.config.rspm }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true - - uses: r-lib/actions/setup-pandoc@v1 - - - 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} - - - name: Restore (or define new) R package cache - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ matrix.config.os }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ matrix.config.os }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install system dependencies (Linux) - if: runner.os == 'Linux' - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'release <- system("lsb_release -rs", intern = TRUE); writeLines(remotes::system_requirements("ubuntu", release))') + cache-version: ${{ secrets.CACHE_VERSION }} + extra-packages: any::rcmdcheck + needs: check - - name: Install system dependencies (macOS) - if: runner.os == 'macOS' - run: | - brew install udunits - brew install gdal - brew install proj - - - name: Install package dependencies - run: | - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("rcmdcheck") - shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_REMOTE_: false - run: | - options(rmarkdown.html_vignette.check_title = FALSE) - rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main - with: - name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results - path: check + - uses: r-lib/actions/check-r-package@v2 diff --git a/.github/workflows/site-deploy.yaml b/.github/workflows/site-deploy.yaml index 53c1212..8a749c9 100644 --- a/.github/workflows/site-deploy.yaml +++ b/.github/workflows/site-deploy.yaml @@ -8,53 +8,23 @@ name: site-deploy jobs: site-deploy: - runs-on: ${{ matrix.config.os }} - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - strategy: - matrix: - config: - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + runs-on: ubuntu-22.04 env: - RSPM: ${{ matrix.config.rspm }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-r@v1 - with: - r-version: ${{ matrix.config.r }} - - - 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} - - - name: Restore (or define new) R package cache - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ matrix.config.os }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} + use-public-rspm: true - - name: Install system dependencies (Linux) - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'release <- system("lsb_release -rs", intern = TRUE); writeLines(remotes::system_requirements("ubuntu", release))') - sudo apt-get install -y libfribidi-dev libharfbuzz-dev - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - install.packages("pkgdown") - shell: Rscript {0} - - - name: Install package - run: R CMD INSTALL . + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + cache-version: ${{ secrets.CACHE_VERSION }} + extra-packages: local::., pkgdown@1.6.1 + needs: website - name: Deploy package run: | diff --git a/.github/workflows/site-devel.yaml b/.github/workflows/site-devel.yaml index 8f05cd1..8df634a 100644 --- a/.github/workflows/site-devel.yaml +++ b/.github/workflows/site-devel.yaml @@ -8,60 +8,30 @@ name: site-devel jobs: site-devel: - runs-on: ${{ matrix.config.os }} - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - strategy: - matrix: - config: - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + runs-on: ubuntu-22.04 env: - RSPM: ${{ matrix.config.rspm }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-r@v1 - with: - r-version: ${{ matrix.config.r }} - - - 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} - - - name: Restore (or define new) R package cache - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ matrix.config.os }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} + use-public-rspm: true - - name: Install system dependencies (Linux) - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'release <- system("lsb_release -rs", intern = TRUE); writeLines(remotes::system_requirements("ubuntu", release))') - sudo apt-get install -y libfribidi-dev libharfbuzz-dev - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - install.packages("pkgdown") - shell: Rscript {0} - - - name: Install package - run: R CMD INSTALL . + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + cache-version: ${{ secrets.CACHE_VERSION }} + extra-packages: local::., pkgdown@1.6.1 + needs: website - name: Build site run: | Rscript -e 'options(rmarkdown.html_vignette.check_title = FALSE); pkgdown::build_site()' - name: Upload pkgdown-site as artifact - uses: actions/upload-artifact@main + uses: actions/upload-artifact@v3 with: name: pkgdown-site path: docs diff --git a/.zenodo.json b/.zenodo.json index c7911f2..4bc6831 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -4,7 +4,7 @@ "license": "GPL-3.0", "upload_type": "software", "access_right": "open", - "version": "0.4.1", + "version": "0.4.2", "creators": [ { "name": "Vanderhaeghe, Floris", diff --git a/DESCRIPTION b/DESCRIPTION index 7496e8d..1ff8d3f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: watina Title: Querying and Processing Data from the INBO Watina Database -Version: 0.4.1 +Version: 0.4.2 Description: The R-package watina contains functions to query and process data from the Watina database at the Research Institute for Nature and Forest (INBO). This database primarily provides @@ -23,7 +23,6 @@ Imports: assertthat, dplyr, inbodb, - KSgeneral, lubridate, rlang, stringr, @@ -32,6 +31,7 @@ Imports: Suggests: DBI, knitr, + KSgeneral, purrr, rmarkdown, sf, @@ -41,5 +41,5 @@ Remotes: inbo/inbodb LazyData: true Encoding: UTF-8 -RoxygenNote: 7.1.1 +RoxygenNote: 7.2.3 VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index 9f5b575..e83f39b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,7 +13,6 @@ export(get_locs) export(get_xg3) export(selectlocs_chem) export(selectlocs_xg3) -importFrom(KSgeneral,disc_ks_test) importFrom(assertthat,assert_that) importFrom(assertthat,has_args) importFrom(assertthat,has_name) diff --git a/NEWS.md b/NEWS.md index 716b1c6..049f466 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# watina 0.4.2 (2023-09-15) + +- Move package {KSgeneral} to `Suggests` (#103). +This avoids package breaking when {KSgeneral} is not available on CRAN. +For the moment not taking further measures to protect against it, as the package is currently back on CRAN. + # watina 0.4.1 (2021-06-11) - Fixed non-working `get_xg3()` and `get_chem()` for dataframe input, by avoiding the currently defunct `dbplyr::db_drop_table()` (#89, [08bc66d](https://github.com/inbo/watina/commit/08bc66d)). diff --git a/R/eval.R b/R/eval.R index e460882..f227b57 100644 --- a/R/eval.R +++ b/R/eval.R @@ -354,8 +354,6 @@ qualify_xg3 <- function(data, #' @importFrom rlang .data #' @importFrom assertthat #' assert_that -#' @importFrom KSgeneral -#' disc_ks_test #' @importFrom stringr #' str_detect #' @importFrom stats @@ -382,6 +380,8 @@ eval_xg3_series <- function(data, max_gap, min_dur) { + require_pkgs("KSgeneral") + if (missing(xg3_type)) { xg3_type <- match.arg(xg3_type)} else { assert_that(all(xg3_type %in% @@ -410,11 +410,13 @@ eval_xg3_series <- function(data, ser_rel_nryears = .data$ser_nryears / .data$ser_length, ser_firstyear = min(.data$hydroyear), ser_lastyear = max(.data$hydroyear), - ser_pval_uniform = disc_ks_test(.data$hydroyear, - ecdf(seq(.data$ser_firstyear, - .data$ser_lastyear)), - exact = TRUE) %>% - .$p.value + ser_pval_uniform = KSgeneral::disc_ks_test( + .data$hydroyear, + ecdf(seq(.data$ser_firstyear, + .data$ser_lastyear)), + exact = TRUE + ) %>% + .$p.value ) %>% ungroup }, @@ -650,6 +652,8 @@ eval_chem <- function(data, type = c("avail", "num", "both"), uniformity_test = FALSE) { + require_pkgs("KSgeneral") + type <- match.arg(type) assert_that(inherits(data, what = c("tbl_lazy", "data.frame")), @@ -774,13 +778,15 @@ date, lab_sample_id, chem_variable, value, unit, below_loq." df %>% summarise( nryears = sum(.data$available), - pval_uniform_totalspan = ifelse(.data$nryears > 0, - disc_ks_test(.data$year[.data$available], - ecdf(seq(firstyear, - lastyear)), - exact = TRUE) %>% - .$p.value, - NA) + pval_uniform_totalspan = ifelse( + .data$nryears > 0, + KSgeneral::disc_ks_test(.data$year[.data$available], + ecdf(seq(firstyear, + lastyear)), + exact = TRUE) %>% + .$p.value, + NA + ) ) %>% select(-.data$nryears) %>% ungroup diff --git a/man/eval_chem.Rd b/man/eval_chem.Rd index 747053f..02384d6 100644 --- a/man/eval_chem.Rd +++ b/man/eval_chem.Rd @@ -6,8 +6,8 @@ \usage{ eval_chem( data, - chem_var = c("P-PO4", "N-NO3", "N-NO2", "N-NH4", "HCO3", "SO4", "Cl", "Na", "K", - "Ca", "Mg", "Fe", "Mn", "Si", "Al", "CondF", "CondL", "pHF", "pHL"), + chem_var = c("P-PO4", "N-NO3", "N-NO2", "N-NH4", "HCO3", "SO4", "Cl", "Na", "K", "Ca", + "Mg", "Fe", "Mn", "Si", "Al", "CondF", "CondL", "pHF", "pHL"), type = c("avail", "num", "both"), uniformity_test = FALSE ) diff --git a/man/selectlocs_chem.Rd b/man/selectlocs_chem.Rd index c8e575c..646aa8a 100644 --- a/man/selectlocs_chem.Rd +++ b/man/selectlocs_chem.Rd @@ -7,8 +7,8 @@ selectlocs_chem( data, data_type = c("data", "summary"), - chem_var = c("P-PO4", "N-NO3", "N-NO2", "N-NH4", "HCO3", "SO4", "Cl", "Na", "K", - "Ca", "Mg", "Fe", "Mn", "Si", "Al", "CondF", "CondL", "pHF", "pHL"), + chem_var = c("P-PO4", "N-NO3", "N-NO2", "N-NH4", "HCO3", "SO4", "Cl", "Na", "K", "Ca", + "Mg", "Fe", "Mn", "Si", "Al", "CondF", "CondL", "pHF", "pHL"), conditions, verbose = TRUE, list = FALSE diff --git a/man/watina-package.Rd b/man/watina-package.Rd index 5575a6a..6754281 100644 --- a/man/watina-package.Rd +++ b/man/watina-package.Rd @@ -6,11 +6,7 @@ \alias{watina-package} \title{watina: Querying and Processing Data from the INBO Watina Database} \description{ -The R-package watina contains functions to query - and process data from the Watina database at the Research Institute for - Nature and Forest (INBO). This database primarily provides - groundwater level and chemical data, mainly from natural - areas in Flanders (Belgium). +The R-package watina contains functions to query and process data from the Watina database at the Research Institute for Nature and Forest (INBO). This database primarily provides groundwater level and chemical data, mainly from natural areas in Flanders (Belgium). } \details{ See the \href{00Index.html}{Index} for an overview of the available functions.