From d3a6139b6ff2b34ad018b6d1c17bf1ddba3a8da4 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Fri, 2 Feb 2024 17:09:13 -0600 Subject: [PATCH] Upkeep 2024 (#492) * Redocument * Add missing S3 methods * use_tidy_description() * use_tidy_github_actions() * Make Hadley maintainer; update company name * Doc fixes * Drop badges --- .Rbuildignore | 1 + .github/workflows/R-CMD-check.yaml | 102 ++++++++------------------- .github/workflows/pr-commands.yaml | 79 +++++++++++++++++++++ .github/workflows/test-coverage.yaml | 50 +++++++++++++ DESCRIPTION | 63 +++++++++-------- NAMESPACE | 4 ++ R/compute_bin.R | 1 + R/compute_boxplot.R | 3 + R/ggvis.R | 2 - R/utils_data.R | 1 + README.md | 4 -- codecov.yml | 14 ++++ man/add_scale.Rd | 3 - man/bin_vector.Rd | 11 +++ 14 files changed, 226 insertions(+), 112 deletions(-) create mode 100644 .github/workflows/pr-commands.yaml create mode 100644 .github/workflows/test-coverage.yaml create mode 100644 codecov.yml diff --git a/.Rbuildignore b/.Rbuildignore index 38e2c968..1abe7129 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -9,3 +9,4 @@ bench ^cran-comments\.md$ ^\.github$ ^CRAN-RELEASE$ +^codecov\.yml$ diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 82195e0e..07c1dfad 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,16 +1,14 @@ -# NOTE: This workflow is overkill for most R packages -# check-standard.yaml is likely a better choice -# usethis::use_github_action("check-standard") will install it. +# 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 # -# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. -# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +# NOTE: This workflow is overkill for most R packages and +# check-standard.yaml is likely a better choice. +# usethis::use_github_action("check-standard") will install it. on: push: - branches: - - master + branches: [main, master] pull_request: - branches: - - master + branches: [main, master] name: R-CMD-check @@ -24,81 +22,41 @@ jobs: fail-fast: false matrix: config: - - {os: macOS-latest, r: 'release'} + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + # Use 3.6 to trigger usage of RTools35 - {os: windows-latest, r: '3.6'} - - {os: ubuntu-16.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest", http-user-agent: "R/4.0.0 (ubuntu-16.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } - - {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + # use 4.1 to check with rtools40's older compiler + - {os: windows-latest, r: '4.1'} + + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + - {os: ubuntu-latest, r: 'oldrel-2'} + - {os: ubuntu-latest, r: 'oldrel-3'} + - {os: ubuntu-latest, r: 'oldrel-4'} 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@v4 + + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@master + - 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@master - - - 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: Cache R packages - if: runner.os != 'Windows' - 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 system dependencies - if: runner.os == 'Linux' - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "16.04"))') - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("rcmdcheck") - shell: Rscript {0} - - - name: Session info - run: | - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_: false - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash + extra-packages: any::rcmdcheck + needs: check - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main + - uses: r-lib/actions/check-r-package@v2 with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check + upload-snapshots: true diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml new file mode 100644 index 00000000..eea58c5c --- /dev/null +++ b/.github/workflows/pr-commands.yaml @@ -0,0 +1,79 @@ +# 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: + issue_comment: + types: [created] + +name: Commands + +jobs: + document: + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }} + name: document + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::roxygen2 + needs: pr-document + + - name: Document + run: roxygen2::roxygenise() + shell: Rscript {0} + + - name: commit + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add man/\* NAMESPACE + git commit -m 'Document' + + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + style: + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }} + name: style + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + + - name: Install dependencies + run: install.packages("styler") + shell: Rscript {0} + + - name: Style + run: styler::style_pkg() + shell: Rscript {0} + + - name: commit + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add \*.R + git commit -m 'Style' + + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 00000000..960234cd --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,50 @@ +# 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: test-coverage + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + 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::covr + needs: coverage + + - name: Test coverage + run: | + covr::codecov( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + shell: Rscript {0} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v4 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/DESCRIPTION b/DESCRIPTION index 303bc2e1..872a730b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,49 +1,50 @@ Package: ggvis Title: Interactive Grammar of Graphics -Description: An implementation of an interactive grammar of graphics, taking the - best parts of 'ggplot2', combining them with the reactive framework of - 'shiny' and drawing web graphics using 'vega'. Version: 0.4.8 Authors@R: c( - person("Winston", "Chang", role = c("aut", "cre"), email = "winston@rstudio.com"), - person("Hadley", "Wickham", role = "aut", email = "hadley@rstudio.com"), - person(family = "RStudio", role = "cph"), - person(family = "jQuery Foundation", role = "cph", - comment = "jQuery library and jQuery UI library"), - person(family = "jQuery contributors", role = c("ctb", "cph"), - comment = "jQuery library; authors listed in inst/www/lib/jquery/AUTHORS.txt"), - person(family = "jQuery UI contributors", role = c("ctb", "cph"), - comment = "jQuery UI library; authors listed in inst/www/lib/jquery-ui/AUTHORS.txt"), - person("Mike", "Bostock", role = c("ctb", "cph"), comment = "D3 library"), - person(family = "D3 contributors", role = "ctb", - comment = "D3 library; authors listed at https://github.com/d3/d3/graphs/contributors"), - person(family = "Trifacta Inc.", role = "cph", - comment = "Vega library"), - person(family = "Vega contributors", role = "ctb", - comment = "Vega library; authors listed at https://github.com/trifacta/vega/graphs/contributors"), + person("Hadley", "Wickham", , "hadley@posit.co", role = c("aut", "cre")), + person("Winston", "Chang", , "winston@posit.co", role = "aut"), + person(, "Posit", role = "cph"), + person(, "jQuery Foundation", role = "cph", + comment = "jQuery library and jQuery UI library"), + person(, "jQuery contributors", role = c("ctb", "cph"), + comment = "jQuery library; authors listed in inst/www/lib/jquery/AUTHORS.txt"), + person(, "jQuery UI contributors", role = c("ctb", "cph"), + comment = "jQuery UI library; authors listed in inst/www/lib/jquery-ui/AUTHORS.txt"), + person("Mike", "Bostock", role = c("ctb", "cph"), + comment = "D3 library"), + person(, "D3 contributors", role = "ctb", + comment = "D3 library; authors listed at https://github.com/d3/d3/graphs/contributors"), + person(, "Trifacta Inc.", role = "cph", + comment = "Vega library"), + person(, "Vega contributors", role = "ctb", + comment = "Vega library; authors listed at https://github.com/trifacta/vega/graphs/contributors"), person("Sebastián", "Décima", role = c("ctb", "cph"), - comment = "javascript-detect-element-resize library") - ) + comment = "javascript-detect-element-resize library") + ) +Description: An implementation of an interactive grammar of graphics, + taking the best parts of 'ggplot2', combining them with the reactive + framework of 'shiny' and drawing web graphics using 'vega'. +License: GPL-2 | file LICENSE URL: https://ggvis.rstudio.com/ Depends: R (>= 3.0) Imports: assertthat, + dplyr (>= 0.5.0), + htmltools (>= 0.2.4), jsonlite (>= 0.9.11), - shiny (>= 0.11.1), magrittr, - dplyr (>= 0.5.0), + methods, rlang, - htmltools (>= 0.2.4), - methods + shiny (>= 0.11.1) Suggests: + knitr (>= 1.6), + lubridate, MASS, mgcv, - lubridate, - testthat (>= 0.8.1), - knitr (>= 1.6), - rmarkdown + rmarkdown, + testthat (>= 0.8.1) Encoding: UTF-8 -License: GPL-2 | file LICENSE LazyData: true -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 diff --git a/NAMESPACE b/NAMESPACE index 7b5831f5..cefd4f51 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -45,6 +45,9 @@ S3method(compute_bin,grouped_df) S3method(compute_boxplot,data.frame) S3method(compute_boxplot,ggvis) S3method(compute_boxplot,grouped_df) +S3method(compute_boxplot_outliers,data.frame) +S3method(compute_boxplot_outliers,ggvis) +S3method(compute_boxplot_outliers,grouped_df) S3method(compute_count,data.frame) S3method(compute_count,ggvis) S3method(compute_count,grouped_df) @@ -68,6 +71,7 @@ S3method(data_range,factor) S3method(distinct,ggvis) S3method(distinct,reactive) S3method(empty,default) +S3method(eval_vector,data.frame) S3method(explain,ggvis) S3method(extract_reactives,default) S3method(extract_reactives,ggvis_props) diff --git a/R/compute_bin.R b/R/compute_bin.R index 3dd29dd3..e492e419 100644 --- a/R/compute_bin.R +++ b/R/compute_bin.R @@ -245,6 +245,7 @@ bin_vector <- function(x, weight = NULL, ...) { } #' @export +#' @rdname bin_vector bin_vector.numeric <- function(x, weight = NULL, ..., width = 1, origin = 0, closed = c("right", "left"), pad = FALSE) { diff --git a/R/compute_boxplot.R b/R/compute_boxplot.R index 5645a6eb..881666e6 100644 --- a/R/compute_boxplot.R +++ b/R/compute_boxplot.R @@ -72,14 +72,17 @@ compute_boxplot.ggvis <- function(x, var = NULL, coef = 1.5) { compute_boxplot_outliers <- function(x) UseMethod("compute_boxplot_outliers") +#' @export compute_boxplot_outliers.grouped_df <- function(x) { dplyr::do(x, compute_boxplot_outliers(.)) } +#' @export compute_boxplot_outliers.data.frame <- function(x) { data.frame(value_ = unlist(x$outliers_)) } +#' @export compute_boxplot_outliers.ggvis <- function(x) { register_computation(x, args = NULL, "boxplot_outliers", function(data, args) { output <- compute_boxplot_outliers(data) diff --git a/R/ggvis.R b/R/ggvis.R index b8b359a4..9def8b82 100644 --- a/R/ggvis.R +++ b/R/ggvis.R @@ -165,8 +165,6 @@ add_mark <- function(vis, type = NULL, props = NULL, data = NULL, #' #' @param vis Visualisation to modify. #' @param scale Scale object -#' @param domain Either a vector with static values for the domain, or -#' a reactive that returns a such a vector. #' @param data_domain Should the domain be controlled by a data set which is #' added to the spec? Should only be set to FALSE in special cases. #' @keywords internal diff --git a/R/utils_data.R b/R/utils_data.R index 0adb5f4b..934a4662 100644 --- a/R/utils_data.R +++ b/R/utils_data.R @@ -168,6 +168,7 @@ cur_data <- function(x) shiny::isolate(x$cur_data()) cur_props <- function(x) x$cur_props eval_vector <- function(x, f) UseMethod("eval_vector") +#' @export eval_vector.data.frame <- function(x, f) { eval(f[[2]], x, environment(f)) } diff --git a/README.md b/README.md index 7e93a76b..3382d656 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,5 @@ # ggvis - -[![R build status](https://github.com/wch/ggvis/workflows/R-CMD-check/badge.svg)](https://github.com/wch/ggvis/actions) - - ## Status ![](https://img.shields.io/badge/lifecycle-dormant-blue.svg) diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..04c55859 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,14 @@ +comment: false + +coverage: + status: + project: + default: + target: auto + threshold: 1% + informational: true + patch: + default: + target: auto + threshold: 1% + informational: true diff --git a/man/add_scale.Rd b/man/add_scale.Rd index 1f6d0e83..c6d5255a 100644 --- a/man/add_scale.Rd +++ b/man/add_scale.Rd @@ -13,9 +13,6 @@ add_scale(vis, scale, data_domain = TRUE) \item{data_domain}{Should the domain be controlled by a data set which is added to the spec? Should only be set to FALSE in special cases.} - -\item{domain}{Either a vector with static values for the domain, or -a reactive that returns a such a vector.} } \description{ Add arbitrary scales to ggvis. diff --git a/man/bin_vector.Rd b/man/bin_vector.Rd index 5265d55d..0872ada3 100644 --- a/man/bin_vector.Rd +++ b/man/bin_vector.Rd @@ -2,9 +2,20 @@ % Please edit documentation in R/compute_bin.R \name{bin_vector} \alias{bin_vector} +\alias{bin_vector.numeric} \title{Bin vectors} \usage{ bin_vector(x, weight = NULL, ...) + +\method{bin_vector}{numeric}( + x, + weight = NULL, + ..., + width = 1, + origin = 0, + closed = c("right", "left"), + pad = FALSE +) } \arguments{ \item{x}{A vector to bin}