From 416f07b7b182d135fb7320bba284bade990d8b5c Mon Sep 17 00:00:00 2001 From: Philippe Grosjean Date: Wed, 1 May 2024 15:51:55 +0200 Subject: [PATCH] Update repo tools --- .Rbuildignore | 11 ++++--- .github/workflows/test-coverage.yaml | 5 ++- .gitignore | 1 + DESCRIPTION | 42 ++++++++++++------------ NEWS.md | 2 +- R/chart-package.R | 6 +++- README.Rmd | 9 +++--- README.md | 26 ++++++++------- _pkgdown.yml | 1 + chart.Rproj | 10 ++++-- inst/CITATION | 7 ++-- inst/WORDLIST | 4 +++ man/chart-package.Rd | 6 ++-- tests/testthat/test-chart.R | 2 +- vignettes/.gitignore | 2 -- vignettes/chart.R | 4 +++ vignettes/chart.Rmd | 17 ++++------ vignettes/chart_rationate.R | 48 +++++++++++++++++++++++++--- vignettes/chart_rationate.Rmd | 8 ++--- 19 files changed, 137 insertions(+), 74 deletions(-) delete mode 100644 vignettes/.gitignore create mode 100644 vignettes/chart.R diff --git a/.Rbuildignore b/.Rbuildignore index 4341bc4..a71ef15 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,19 +1,20 @@ -^\.DS_Store$ ^\.Rproj\.user$ ^.+\.Rproj$ ^\.gitignore$ ^\.git$ ^\.github$ +^\.DS_Store$ ^Makefile$ ^\.Rprofile$ ^revdep$ ^codecov\.yml$ +^_pkgdown\.yml$ +^pkgdown$ +^docs$ ^CODE_OF_CONDUCT\.md$ ^FAQ\.md$ ^LICENSE\.md$ ^README\.Rmd$ -^README\.Rmd$ +^README\.md$ ^TODO\.md$ -^_pkgdown\.yml$ -^pkgdown$ -^docs$ +data-raw diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 21b8a93..e5f9ed2 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -13,6 +13,7 @@ jobs: runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} steps: - uses: actions/checkout@v4 @@ -28,10 +29,12 @@ jobs: - name: Test coverage run: | + token <- Sys.getenv("CODECOV_TOKEN", "") covr::codecov( quiet = FALSE, clean = FALSE, - install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package"), + token = if (token != "") token ) shell: Rscript {0} diff --git a/.gitignore b/.gitignore index 5c3f9df..e3ca40d 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,4 @@ rsconnect/ # More files inst/doc docs +Meta diff --git a/DESCRIPTION b/DESCRIPTION index f466908..0b768a7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,27 +13,27 @@ Maintainer: Philippe Grosjean Depends: R (>= 4.2.0), ggplot2 (>= 3.0), - lattice + lattice (>= 0.21.0) Imports: - cowplot, - data.io, - ggplotify, - ggpubr, - graphics, - grDevices, - latticeExtra, - pryr, - rlang, - scales, - stats, - utils, - viridis, - svMisc + cowplot (>= 1.1.1), + data.io (>= 1.5.0), + ggplotify (>= 0.1.0), + ggpubr (>= 0.6.0), + graphics (>= 4.2.0), + grDevices (>= 4.2.0), + latticeExtra (>= 0.6.30), + pryr (>= 0.1.6), + rlang (>= 1.1.1), + scales (>= 1.2.1), + stats (>= 4.2.0), + svMisc (>= 1.4.0), + utils (>= 4.2.0), + viridis (>= 0.6.2) Suggests: - MASS, - knitr, - rmarkdown, - spelling, + MASS (>= 7.3.58.3), + knitr (>= 1.42), + rmarkdown (>= 2.21), + spelling (>= 2.2.1), testthat (>= 3.0.0) Remotes: SciViews/data.io, @@ -41,10 +41,10 @@ Remotes: License: MIT + file LICENSE URL: https://github.com/SciViews/chart, https://www.sciviews.org/chart/ BugReports: https://github.com/SciViews/chart/issues -ByteCompile: yes Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 -Config/testthat/edition: 3 VignetteBuilder: knitr Encoding: UTF-8 Language: en-US +ByteCompile: yes +Config/testthat/edition: 3 diff --git a/NEWS.md b/NEWS.md index 00990e7..0d66791 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # chart 1.5.2 -- Documentation (vignettes et README file) are completed. +- Documentation (vignettes and README file) are completed. - License change to MIT for better reusability. diff --git a/R/chart-package.R b/R/chart-package.R index 4248b26..7d2422c 100644 --- a/R/chart-package.R +++ b/R/chart-package.R @@ -5,7 +5,11 @@ #' #' @section Important functions: #' -#'- [chart()] constructs a `Chart` object. +#'- [chart()] constructs a **Chart** object. +#' +#'- [combine_charts()] combines multiple **Chart** objects into a single plot. +#' +#'- [f_aes()] creates a formula for aesthetics mapping (use it instead of [ggplot2::aes()]. #' #' @docType package #' @name chart-package diff --git a/README.Rmd b/README.Rmd index ccd77e8..0608b8d 100644 --- a/README.Rmd +++ b/README.Rmd @@ -7,8 +7,8 @@ output: github_document -[![R-CMD-check](https://github.com/SciViews/chart/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/SciViews/chart/actions/workflows/R-CMD-check.yaml) [![Coverage status](https://img.shields.io/codecov/c/github/SciViews/chart/master.svg)](https://codecov.io/github/SciViews/chart?branch=main) [![CRAN status](https://www.r-pkg.org/badges/version/chart)](https://cran.r-project.org/package=chart) [![License](https://img.shields.io/badge/license-GPL-blue.svg)](https://www.gnu.org/licenses/gpl-2.0.html) [![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable) -[![Codecov test coverage](https://codecov.io/gh/SciViews/chart/branch/main/graph/badge.svg)](https://app.codecov.io/gh/SciViews/chart?branch=main) +[![R-CMD-check](https://github.com/SciViews/chart/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/SciViews/chart/actions/workflows/R-CMD-check.yaml) [![Codecov test coverage](https://codecov.io/gh/SciViews/chart/branch/main/graph/badge.svg)](https://app.codecov.io/gh/SciViews/chart?branch=main) [![CRAN status](https://www.r-pkg.org/badges/version/chart)](https://cran.r-project.org/package=chart) [![r-universe status](https://sciviews.r-universe.dev/badges/chart)](https://sciviews.r-universe.dev/chart) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) + ```{r setup, include=FALSE} @@ -18,7 +18,7 @@ library(chart) ``` -{chart} provides an alternate formula interface to {ggplot2}, and it also homogenize plot outputs from base R plots, {lattice} and {ggplot}. If labels and/or units attributes are defined for variables in the data, they are used automatically to construct the label (with units) of the axes. See for more details. +The {chart} package provides an alternate formula interface to {ggplot2}, and it also homogenize plot outputs from base R plots, {lattice} and {ggplot}. If labels and/or units attributes are defined for variables in the data, they are used automatically to construct the label (with units) of the axes. See for more details. ## Installation @@ -57,7 +57,6 @@ airquality <- data.io::labelise(airquality, label = list( )) ``` - here is a first {chart}: ```{r} @@ -80,4 +79,4 @@ vignette("chart") # Not installed with install_github() ## Code of Conduct -Please note that the {chart} package is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms. +Please note that the {chart} package is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms. diff --git a/README.md b/README.md index c67aa56..02b84a1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Chart - Unified Interface (with Formula) for R Plots +Unified Interface (with Formula) for R Plots ================ @@ -6,21 +6,25 @@ Chart - Unified Interface (with Formula) for R Plots [![R-CMD-check](https://github.com/SciViews/chart/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/SciViews/chart/actions/workflows/R-CMD-check.yaml) -[![Coverage -status](https://img.shields.io/codecov/c/github/SciViews/chart/master.svg)](https://codecov.io/github/SciViews/chart?branch=main) +[![Codecov test +coverage](https://codecov.io/gh/SciViews/chart/branch/main/graph/badge.svg)](https://app.codecov.io/gh/SciViews/chart?branch=main) [![CRAN status](https://www.r-pkg.org/badges/version/chart)](https://cran.r-project.org/package=chart) -[![License](https://img.shields.io/badge/license-GPL-blue.svg)](https://www.gnu.org/licenses/gpl-2.0.html) +[![r-universe +status](https://sciviews.r-universe.dev/badges/chart)](https://sciviews.r-universe.dev/chart) +[![License: +MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Lifecycle: -stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable) +stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) -{chart} provides an alternate formula interface to {ggplot2}, and it -also homogenize plot outputs from base R plots, {lattice} and {ggplot}. -If labels and/or units attributes are defined for variables in the data, -they are used automatically to construct the label (with units) of the -axes. See for more details. +The {chart} package provides an alternate formula interface to +{ggplot2}, and it also homogenize plot outputs from base R plots, +{lattice} and {ggplot}. If labels and/or units attributes are defined +for variables in the data, they are used automatically to construct the +label (with units) of the axes. See +for more details. ## Installation @@ -108,5 +112,5 @@ vignette("chart") # Not installed with install_github() Please note that the {chart} package is released with a [Contributor Code of -Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). +Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms. diff --git a/_pkgdown.yml b/_pkgdown.yml index 79b1468..8d838f6 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -7,6 +7,7 @@ development: template: package: svPkgdown + bootstrap: 5 params: bootswatch: spacelab mathjax: true diff --git a/chart.Rproj b/chart.Rproj index 6fccb25..a4dc148 100644 --- a/chart.Rproj +++ b/chart.Rproj @@ -1,7 +1,7 @@ Version: 1.0 -RestoreWorkspace: Default -SaveWorkspace: Default +RestoreWorkspace: No +SaveWorkspace: No AlwaysSaveHistory: Default EnableCodeIndexing: Yes @@ -14,8 +14,14 @@ LaTeX: XeLaTeX AutoAppendNewline: Yes StripTrailingWhitespace: Yes +LineEndingConversion: Posix BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source +PackageCheckArgs: --as-cran PackageRoxygenize: rd,collate,namespace,vignette + +QuitChildProcessesOnExit: Yes + +SpellingDictionary: en_US diff --git a/inst/CITATION b/inst/CITATION index f75bfbb..5be4aa1 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -1,16 +1,17 @@ -citHeader("To cite SciViews-R in publications, please use:") +citHeader("To cite SciViews-R in publications use:") citEntry( entry = "Manual", title = "SciViews::R", - author = personList(as.person("Philippe Grosjean")), + author = personList(as.person("Philippe Grosjean"), + as.person("Guyliann Engels")), organization = "UMONS", address = "MONS, Belgium", year = version$year, url = "https://sciviews.r-universe.dev/", textVersion = - paste("Grosjean, Ph. (", version$year, "). ", + paste("Grosjean, Ph. & Engels, G. (", version$year, "). ", "SciViews::R. ", "UMONS, Mons, Belgium. ", "URL https://sciviews.r-universe.dev/.", diff --git a/inst/WORDLIST b/inst/WORDLIST index dd4e923..0a97ac2 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,10 +1,14 @@ aes appveyor +customizable devtools +exploreit ggplot GitHub +modelit OSX pipeable +reusability subsettable thetics viridis diff --git a/man/chart-package.Rd b/man/chart-package.Rd index 1a4f14a..ef4b866 100644 --- a/man/chart-package.Rd +++ b/man/chart-package.Rd @@ -3,7 +3,7 @@ \docType{package} \name{chart-package} \alias{chart-package} -\title{Chart, unified interface for R plots} +\title{Unified Interface (with Formula) for R Plots} \description{ Unification of base plots, lattice and ggplot2, providing a single interface for all three plot engines. @@ -11,7 +11,9 @@ for all three plot engines. \section{Important functions}{ \itemize{ -\item \code{\link[=chart]{chart()}} constructs a \code{Chart} object. +\item \code{\link[=chart]{chart()}} constructs a \strong{Chart} object. +\item \code{\link[=combine_charts]{combine_charts()}} combines multiple \strong{Chart} objects into a single plot. +\item \code{\link[=f_aes]{f_aes()}} creates a formula for aesthetics mapping (use it instead of \code{\link[ggplot2:aes]{ggplot2::aes()}}. } } diff --git a/tests/testthat/test-chart.R b/tests/testthat/test-chart.R index 8311eae..4ad6de0 100644 --- a/tests/testthat/test-chart.R +++ b/tests/testthat/test-chart.R @@ -1,4 +1,4 @@ -test_that("chart creates 'Chart' objects", { +test_that("chart() creates Chart objects", { dtf <- data.frame(x = 1:2, y = 1:2) expect_s3_class(chart(dtf, y ~ x), 'Chart') }) diff --git a/vignettes/.gitignore b/vignettes/.gitignore deleted file mode 100644 index 097b241..0000000 --- a/vignettes/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.html -*.R diff --git a/vignettes/chart.R b/vignettes/chart.R new file mode 100644 index 0000000..14ae76d --- /dev/null +++ b/vignettes/chart.R @@ -0,0 +1,4 @@ +## ----setup, include=FALSE----------------------------------------------------- +knitr::opts_chunk$set(collapse = TRUE, comment = "#>") +library(chart) + diff --git a/vignettes/chart.Rmd b/vignettes/chart.Rmd index e9226ed..2aca4d7 100644 --- a/vignettes/chart.Rmd +++ b/vignettes/chart.Rmd @@ -1,23 +1,20 @@ --- -title: "Chart - Unified Interface (with Formula) for R Plots" -author: "Philippe Grosjean (phgrosjean@sciviews.org)" +title: "Unified Interface (with Formula) for R Plots" +author: "Philippe Grosjean" date: "`r Sys.Date()`" output: rmarkdown::html_vignette: toc: true toc_depth: 3 + fig_caption: yes vignette: > - %\VignetteIndexEntry{Chart - Unified Interface (with Formula) for R Plots} + %\VignetteIndexEntry{Unified Interface (with Formula) for R Plots} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} - \usepackage[utf8]{inputenc} --- ```{r setup, include=FALSE} -knitr::opts_chunk$set( - collapse = TRUE, - comment = "#>" -) +knitr::opts_chunk$set(collapse = TRUE, comment = "#>") library(chart) ``` @@ -28,11 +25,11 @@ In R, there are several plotting engines, but the three major ones are the base The goal of {chart} is: - to provide a unified interface to the three major plotting engines in R; -- to make all three types of plots intercompatible in a composite figure; +- to make all three types of plots compatible in a composite figure; - to propose a default style for the plots that is consistent across the three engines and close enough to a publication-ready style; - to use automatically labels and units for axes, when possible; - to expose an formula-base interface as an alternative for {ggplot2} users; -- to implement various (customisable) plot types for different R objects. +- to implement various (customizable) plot types for different R objects. ## {chart} for {ggplot2} users diff --git a/vignettes/chart_rationate.R b/vignettes/chart_rationate.R index 59c32bd..697c098 100644 --- a/vignettes/chart_rationate.R +++ b/vignettes/chart_rationate.R @@ -1,6 +1,44 @@ -## ----setup, include = FALSE---------------------------------------------- -knitr::opts_chunk$set( - collapse = TRUE, - comment = "#>" -) +## ----setup, include=FALSE----------------------------------------------------- +knitr::opts_chunk$set(collapse = TRUE, comment = "#>", + fig.width = 6, fig.height = 4.5, out.width = "95%") +library(chart) + +## ----------------------------------------------------------------------------- +data(trees) +trees_lm <- lm(Volume ~ Girth, data = trees) +summary(trees_lm) + +## ----------------------------------------------------------------------------- +library(ggplot2) +ggplot(trees, aes(x = Girth, y = Volume)) + + geom_point() + + geom_smooth(method = "lm", formula = 'y ~ x') + +## ----------------------------------------------------------------------------- +library(chart) +chart(trees, Volume ~ Girth) + + geom_point() + + geom_smooth(method = "lm", formula = 'y ~ x') + +## ----------------------------------------------------------------------------- +chart(trees, Volume ~ Girth %col=% Height) + + geom_point() + +## ----------------------------------------------------------------------------- +chart(function() { + plot(Volume ~ Girth, data = trees, pch = 19, col = "black") + grid(lty = "solid") +}) + +## ----------------------------------------------------------------------------- +trees <- data.io::labelise(trees, label = list( + Volume = "Volume of timber", + Girth = "Diameter at 1.4m", + Height = "Height" + ), units = list( + Volume = "cubic feet", + Girth = "inches", + Height = "feet")) +chart(trees, Volume ~ Girth %col=% Height) + + geom_point() diff --git a/vignettes/chart_rationate.Rmd b/vignettes/chart_rationate.Rmd index ec5735f..0f682a0 100644 --- a/vignettes/chart_rationate.Rmd +++ b/vignettes/chart_rationate.Rmd @@ -1,19 +1,19 @@ --- title: "Why Chart?" -author: "Philippe Grosjean (phgrosjean@sciviews.org)" +author: "Philippe Grosjean" date: "`r Sys.Date()`" output: rmarkdown::html_vignette: toc: true toc_depth: 3 + fig_caption: yes vignette: > %\VignetteIndexEntry{Why Chart?} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} - \usepackage[utf8]{inputenc} --- -```{r setup, include = FALSE} +```{r setup, include=FALSE} knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 4.5, out.width = "95%") library(chart) @@ -49,7 +49,7 @@ chart(trees, Volume ~ Girth) + geom_smooth(method = "lm", formula = 'y ~ x') ``` -Of course, it is not necessarily the **same** formula that is used for the model and the chart. The formula interface has different meaning, depending on the function that uses it. To specify more aestethics in {chart} than just `x` and `y`, we use `%arg=%` terms. For instance, to specify the color of the points, we use `%col=%`: +Of course, it is not necessarily the **same** formula that is used for the model and the chart. The formula interface has different meaning, depending on the function that uses it. To specify more aesthetics in {chart} than just `x` and `y`, we use `%arg=%` terms. For instance, to specify the color of the points, we use `%col=%`: ```{r} chart(trees, Volume ~ Girth %col=% Height) +