From af5aa932a5d3e76fe9e932677271a4c130abc516 Mon Sep 17 00:00:00 2001 From: Mauro Lepore Date: Wed, 9 Jun 2021 12:48:45 -0600 Subject: [PATCH 1/6] Polish cran_comments.md --- cran-comments.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index 374b4f16..4010f4b9 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,7 +1,7 @@ ## Test environments -* ubuntu 18.04 (local), R 4.0.3 -* ubuntu 16.04 (github actions), R-oldrel, R-release, R-devel +* ubuntu 18.04 (local), R 4.1.0 +* ubuntu 18.04 (github actions), R-oldrel, R-release, R-devel * macOS-latest (github actions), R-release * windows-latest (github actions), R-oldrel, R-release * win-builder, R-release, R-devel From 4f3639428ac7090fc51857b154548ee2c3f500a9 Mon Sep 17 00:00:00 2001 From: Mauro Lepore Date: Wed, 9 Jun 2021 12:50:46 -0600 Subject: [PATCH 2/6] Update GH actions workflow for R CMD check --- .github/workflows/R-CMD-check.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 86411f47..78155482 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -28,10 +28,11 @@ jobs: config: - {os: macOS-latest, r: 'release'} - {os: windows-latest, r: 'release'} - - {os: windows-latest, r: '3.6'} - - {os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } + - {os: windows-latest, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/latest"} + - {os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.1.0 (ubuntu-18.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - {os: ubuntu-18.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-18.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - {os: ubuntu-18.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - {os: ubuntu-18.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} @@ -60,7 +61,7 @@ jobs: uses: actions/cache@v2 with: path: | - ${{ env.R_LIBS_USER }} + ${{ env.R_LIBS_USER }}/* !${{ env.R_LIBS_USER }}/pak key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1- @@ -104,3 +105,8 @@ jobs: with: name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results path: check + + - name: Don't use tar from old Rtools to store the cache + if: ${{ runner.os == 'Windows' && startsWith(steps.install-r.outputs.installed-r-version, '3.6' ) }} + shell: bash + run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH From bb974d235d55927981dab0ea528816fc650e3cde Mon Sep 17 00:00:00 2001 From: Mauro Lepore Date: Wed, 9 Jun 2021 13:14:40 -0600 Subject: [PATCH 3/6] All exported functions now have return and value --- R/plot_techmixX.R | 6 +++--- R/plot_techmixY.R | 2 ++ R/plot_timelineX.R | 6 +++--- R/plot_timelineY.R | 1 + R/plot_trajectoryX.R | 6 +++--- R/plot_trajectoryY.R | 2 ++ R/prep_techmixY.R | 2 ++ R/prep_timelineY.R | 2 +- R/theme_2dii.R | 1 + R/timeline_specs.R | 2 ++ man/plot_techmixX.Rd | 2 +- man/plot_techmixY.Rd | 3 +++ man/plot_timelineX.Rd | 2 +- man/plot_trajectoryX.Rd | 2 +- man/plot_trajectoryY.Rd | 3 +++ man/prep_techmixY.Rd | 3 +++ 16 files changed, 32 insertions(+), 13 deletions(-) diff --git a/R/plot_techmixX.R b/R/plot_techmixX.R index 76a3e06b..54ac37bd 100644 --- a/R/plot_techmixX.R +++ b/R/plot_techmixX.R @@ -7,12 +7,12 @@ #' * The column `metric` must have a portfolio (e.g. "projected"), a benchmark #' (e.g. "corporate_economy"), and a single `scenario` (e.g. "target_sds"). #' -#' @return A "ggplot". -#' @export -#' #' @family functions with minimal arguments #' @seealso [market_share]. #' +#' @return An object of class "ggplot". +#' +#' @export #' @examples #' library(dplyr, warn.conflicts = FALSE) #' diff --git a/R/plot_techmixY.R b/R/plot_techmixY.R index e3fc0e62..751a82a4 100644 --- a/R/plot_techmixY.R +++ b/R/plot_techmixY.R @@ -15,6 +15,8 @@ #' #' @family plotting functions #' +#' @return An object of class "ggplot". +#' #' @export #' @examples #' data <- prep_techmixY( diff --git a/R/plot_timelineX.R b/R/plot_timelineX.R index dcffef98..4044ea06 100644 --- a/R/plot_timelineX.R +++ b/R/plot_timelineX.R @@ -6,12 +6,12 @@ #' @inheritParams prep_timelineY #' @inheritParams plot_timelineY #' -#' @return A "ggplot". -#' @export -#' #' @family functions with minimal arguments #' @seealso [sda]. #' +#' @return An object of class "ggplot". +#' +#' @export #' @examples #' library(dplyr, warn.conflicts = FALSE) #' diff --git a/R/plot_timelineY.R b/R/plot_timelineY.R index a2fb08b1..b6faafff 100644 --- a/R/plot_timelineY.R +++ b/R/plot_timelineY.R @@ -15,6 +15,7 @@ #' allows custom recoding via a data frame passed to the argument `specs`. #' #' @seealso [sda], [timeline_specs]. +#' #' @return An object of class "ggplot". #' #' @export diff --git a/R/plot_trajectoryX.R b/R/plot_trajectoryX.R index 443d941a..76bbda35 100644 --- a/R/plot_trajectoryX.R +++ b/R/plot_trajectoryX.R @@ -10,12 +10,12 @@ #' @inheritParams prep_trajectoryY #' @inheritParams prep_timelineY #' -#' @return A "ggplot". -#' @export -#' #' @family functions with minimal arguments #' @seealso [market_share]. #' +#' @return An object of class "ggplot". +#' +#' @export #' @examples #' library(dplyr, warn.conflicts = FALSE) #' diff --git a/R/plot_trajectoryY.R b/R/plot_trajectoryY.R index a0c6a58d..803945da 100644 --- a/R/plot_trajectoryY.R +++ b/R/plot_trajectoryY.R @@ -23,6 +23,8 @@ #' #' @family plotting functions #' +#' @return An object of class "ggplot". +#' #' @export #' @examples #' data <- prep_trajectoryY( diff --git a/R/prep_techmixY.R b/R/prep_techmixY.R index 12b7b6bc..e8534cb4 100644 --- a/R/prep_techmixY.R +++ b/R/prep_techmixY.R @@ -9,6 +9,8 @@ #' @param scenario_filter String of length 1. Scenario to pick from the `data`. #' @inheritParams prep_timelineY #' +#' @return An object of class "ggplot". +#' #' @export #' @examples #' prep_techmixY( diff --git a/R/prep_timelineY.R b/R/prep_timelineY.R index ccb34344..772ed311 100644 --- a/R/prep_timelineY.R +++ b/R/prep_timelineY.R @@ -12,8 +12,8 @@ #' @seealso [sda]. #' #' @return Data frame with columns: year, line_name, value, extrapolated. -#' @export #' +#' @export #' @examples #' library(dplyr, warn.conflicts = FALSE) #' diff --git a/R/theme_2dii.R b/R/theme_2dii.R index 23dd2304..7daa6a13 100644 --- a/R/theme_2dii.R +++ b/R/theme_2dii.R @@ -8,6 +8,7 @@ #' @family plotting functions #' #' @return An object of class `r toString(class(theme_2dii()))`. +#' #' @export #' @examples #' library(ggplot2, warn.conflicts = FALSE) diff --git a/R/timeline_specs.R b/R/timeline_specs.R index 6393c5ca..79ca8883 100644 --- a/R/timeline_specs.R +++ b/R/timeline_specs.R @@ -3,7 +3,9 @@ #' @inheritParams plot_timelineY #' #' @seealso plot_timelineA +#' #' @return A data frame useful as the `specs` argument of [plot_timelineY()]. +#' #' @export #' @examples #' data <- prep_timelineY(sda, sector_filter = "cement") diff --git a/man/plot_techmixX.Rd b/man/plot_techmixX.Rd index 591af251..162015fe 100644 --- a/man/plot_techmixX.Rd +++ b/man/plot_techmixX.Rd @@ -17,7 +17,7 @@ plot_techmixX(data) }} } \value{ -A "ggplot". +An object of class "ggplot". } \description{ Create a techmix plot diff --git a/man/plot_techmixY.Rd b/man/plot_techmixY.Rd index 94231015..8eaa41a5 100644 --- a/man/plot_techmixY.Rd +++ b/man/plot_techmixY.Rd @@ -24,6 +24,9 @@ in 'metric type order'.} \item{tech_colours}{Data frame containing colours per technology, with columns: technology, colour, label(optional).} } +\value{ +An object of class "ggplot". +} \description{ The function returns a ggplot object containing a stacked bar chart showing a technology mix for different categories (portfolio, scenario, benchmark, diff --git a/man/plot_timelineX.Rd b/man/plot_timelineX.Rd index ba0de624..1a7db6d4 100644 --- a/man/plot_timelineX.Rd +++ b/man/plot_timelineX.Rd @@ -17,7 +17,7 @@ plot_timelineX(data, extrapolate = FALSE) furthest value in the data set.} } \value{ -A "ggplot". +An object of class "ggplot". } \description{ Create a timeline plot diff --git a/man/plot_trajectoryX.Rd b/man/plot_trajectoryX.Rd index 98895524..7cc1cbc9 100644 --- a/man/plot_trajectoryX.Rd +++ b/man/plot_trajectoryX.Rd @@ -21,7 +21,7 @@ the most visual salience (solid black line). \code{NULL} defaults to "projected".} } \value{ -A "ggplot". +An object of class "ggplot". } \description{ Create a trajectory plot diff --git a/man/plot_trajectoryY.Rd b/man/plot_trajectoryY.Rd index d214561d..7c5f9fd1 100644 --- a/man/plot_trajectoryY.Rd +++ b/man/plot_trajectoryY.Rd @@ -26,6 +26,9 @@ should be plotted as the main line; with columns: metric, label.} additional metrics that should be plotted as lines; with columns: metric, label).} } +\value{ +An object of class "ggplot". +} \description{ We are exploring different interfaces before release. We are keen to hear feedback from beta-testers like you. Please try these diff --git a/man/prep_techmixY.Rd b/man/prep_techmixY.Rd index 55f63e04..d91575db 100644 --- a/man/prep_techmixY.Rd +++ b/man/prep_techmixY.Rd @@ -36,6 +36,9 @@ to plot.} \item{scenario_filter}{String of length 1. Scenario to pick from the \code{data}.} } +\value{ +An object of class "ggplot". +} \description{ Prepare the output of \code{r2dii.analysis::target_market_share()} for \code{plot_techmixY()} } From 05868cb30d56df29ca4579f0d107e4025ba1ca58 Mon Sep 17 00:00:00 2001 From: Mauro Lepore Date: Wed, 9 Jun 2021 13:30:05 -0600 Subject: [PATCH 4/6] Polish internal documentation --- R/colours.R | 13 ------- R/r2dii_colours.R | 32 ++++++++++++++++ data-raw/{colours.R => r2dii_colours.R} | 0 man/palette_colours.Rd | 27 ------------- man/r2dii_colours.Rd | 51 +++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 40 deletions(-) delete mode 100644 R/colours.R create mode 100644 R/r2dii_colours.R rename data-raw/{colours.R => r2dii_colours.R} (100%) delete mode 100644 man/palette_colours.Rd create mode 100644 man/r2dii_colours.Rd diff --git a/R/colours.R b/R/colours.R deleted file mode 100644 index 5724e11d..00000000 --- a/R/colours.R +++ /dev/null @@ -1,13 +0,0 @@ -#' Colour datasets -#' -#' All datasets have at least two columns: -#' * `label`: Text label of the colour. -#' * `hex`: Hex code of the colour. -#' -#' In `scenario_colours`, colours are ordered from red to green to be used in -#' trajectory charts. -#' -#' @aliases scenario_colours sector_colours technology_colours -#' @keywords internal -"palette_colours" - diff --git a/R/r2dii_colours.R b/R/r2dii_colours.R new file mode 100644 index 00000000..6f2e9d23 --- /dev/null +++ b/R/r2dii_colours.R @@ -0,0 +1,32 @@ +#' Colour datasets +#' +#' All datasets have at least two columns: +#' * `label`: Text label of the colour. +#' * `hex`: Hex code of the colour. +#' +#' In `scenario_colours`, colours are ordered from red to green to be used in +#' trajectory charts. +#' +#' @name r2dii_colours +#' @keywords internal +#' +#' @examples +#' r2dii.plot:::palette_colours +#' +#' r2dii.plot:::scenario_colours +#' +#' r2dii.plot:::sector_colours +#' +#' r2dii.plot:::technology_colours +#' +NULL + +#' @rdname r2dii_colours +"palette_colours" +#' @rdname r2dii_colours +"scenario_colours" +#' @rdname r2dii_colours +"sector_colours" +#' @rdname r2dii_colours +"technology_colours" + diff --git a/data-raw/colours.R b/data-raw/r2dii_colours.R similarity index 100% rename from data-raw/colours.R rename to data-raw/r2dii_colours.R diff --git a/man/palette_colours.Rd b/man/palette_colours.Rd deleted file mode 100644 index 7524f1c2..00000000 --- a/man/palette_colours.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/colours.R -\docType{data} -\name{palette_colours} -\alias{palette_colours} -\alias{scenario_colours} -\alias{sector_colours} -\alias{technology_colours} -\title{Colour datasets} -\format{ -An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 9 rows and 2 columns. -} -\usage{ -palette_colours -} -\description{ -All datasets have at least two columns: -\itemize{ -\item \code{label}: Text label of the colour. -\item \code{hex}: Hex code of the colour. -} -} -\details{ -In \code{scenario_colours}, colours are ordered from red to green to be used in -trajectory charts. -} -\keyword{internal} diff --git a/man/r2dii_colours.Rd b/man/r2dii_colours.Rd new file mode 100644 index 00000000..28e2049e --- /dev/null +++ b/man/r2dii_colours.Rd @@ -0,0 +1,51 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/r2dii_colours.R +\docType{data} +\name{r2dii_colours} +\alias{r2dii_colours} +\alias{palette_colours} +\alias{scenario_colours} +\alias{sector_colours} +\alias{technology_colours} +\title{Colour datasets} +\format{ +An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 9 rows and 2 columns. + +An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 5 rows and 2 columns. + +An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 8 rows and 2 columns. + +An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 18 rows and 4 columns. +} +\usage{ +palette_colours + +scenario_colours + +sector_colours + +technology_colours +} +\description{ +All datasets have at least two columns: +\itemize{ +\item \code{label}: Text label of the colour. +\item \code{hex}: Hex code of the colour. +} +} +\details{ +In \code{scenario_colours}, colours are ordered from red to green to be used in +trajectory charts. +} +\examples{ +r2dii.plot:::palette_colours + +r2dii.plot:::scenario_colours + +r2dii.plot:::sector_colours + +r2dii.plot:::technology_colours + +} +\keyword{datasets} +\keyword{internal} From b74ec94615f1df7b30123d65288bb99ec7867f7b Mon Sep 17 00:00:00 2001 From: Mauro Lepore Date: Wed, 9 Jun 2021 13:50:48 -0600 Subject: [PATCH 5/6] Avoid problems with URLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit urlchecker::url_check(): ✖ Error: README.md:14:59 404: Not Found status](https://www.r-pkg.org/badges/version/r2dii.plot)](https://CRAN.R-project.org/package=r2dii.plot) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- README.Rmd | 1 - README.md | 18 ++++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/README.Rmd b/README.Rmd index aac55614..cf609093 100644 --- a/README.Rmd +++ b/README.Rmd @@ -21,7 +21,6 @@ knitr::opts_chunk$set( experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html) [![Codecov test coverage](https://codecov.io/gh/2DegreesInvesting/r2dii.plot/branch/master/graph/badge.svg)](https://codecov.io/gh/2DegreesInvesting/r2dii.plot?branch=master) [![R-CMD-check](https://github.com/2DegreesInvesting/r2dii.plot/workflows/R-CMD-check/badge.svg)](https://github.com/2DegreesInvesting/r2dii.plot/actions) -[![CRAN status](https://www.r-pkg.org/badges/version/r2dii.plot)](https://CRAN.R-project.org/package=r2dii.plot) ```{r echo=FALSE} diff --git a/README.md b/README.md index acd98fe9..1cc30b5d 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,6 @@ experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](h [![Codecov test coverage](https://codecov.io/gh/2DegreesInvesting/r2dii.plot/branch/master/graph/badge.svg)](https://codecov.io/gh/2DegreesInvesting/r2dii.plot?branch=master) [![R-CMD-check](https://github.com/2DegreesInvesting/r2dii.plot/workflows/R-CMD-check/badge.svg)](https://github.com/2DegreesInvesting/r2dii.plot/actions) -[![CRAN -status](https://www.r-pkg.org/badges/version/r2dii.plot)](https://CRAN.R-project.org/package=r2dii.plot) The goal of r2dii.plot is to help you plot 2DII data in an informative, @@ -94,13 +92,13 @@ sets of functions ([API](https://en.wikipedia.org/wiki/API)s) – X and Y. Both APIs can help you get the same plots. The difference is not in what you can do but in how you can do it: - - The X API has a simpler interface. It focuses exclusively on the +- The X API has a simpler interface. It focuses exclusively on the tasks you can’t easily achieve with other packages, and assumes you can meet the `data` requirements and customize your plots with other packages such as base R, dplyr, and ggplot2. It forces you to learn or reuse your existing knowledge of other R packages and workflows. - - The Y API has a more complex but complete toolkit. It offers more +- The Y API has a more complex but complete toolkit. It offers more functions and arguments that wrap features from other packages to help you meet the `data` requirements and customize your plots directly with r2dii.plot. and ggplot2. It forces you to learn the @@ -111,7 +109,7 @@ These tables summarize the differences for users and developers of r2dii.plot: | | X API | Y API | -| :--------------------------------------------- | :------------------ | :-------------------------------------------- | +|:-----------------------------------------------|:--------------------|:----------------------------------------------| | Interface | Simpler | More complex | | Meet `data` requirements | With other packages | With r2dii.plot and optionally other packages | | Customize plots | With other packages | With r2dii.plot and optionally other packages | @@ -120,7 +118,7 @@ r2dii.plot: *The X and Y APIs compared from a user’s perspective.* | | X API | Y API | -| :--------------- | :---- | :---- | +|:-----------------|:------|:------| | Easy to maintain | Less | More | | Easy to extend | More | Less | @@ -134,9 +132,7 @@ API](https://2degreesinvesting.github.io/r2dii.plot/articles/articles/r2dii-plot articles. Notice the resulting plot is almost the same (except for the labels) but the toolkit is different. - - X API - - +- X API ``` r data <- market_share @@ -156,9 +152,7 @@ plot_trajectoryX(prep) + - - Y API - - +- Y API ``` r data <- market_share From 422eef403192fc1a455526b2333f5a95f2b192ef Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 9 Jun 2021 20:35:24 +0000 Subject: [PATCH 6/6] Re-build README.Rmd --- README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1cc30b5d..ad9a6ff1 100644 --- a/README.md +++ b/README.md @@ -92,13 +92,13 @@ sets of functions ([API](https://en.wikipedia.org/wiki/API)s) – X and Y. Both APIs can help you get the same plots. The difference is not in what you can do but in how you can do it: -- The X API has a simpler interface. It focuses exclusively on the + - The X API has a simpler interface. It focuses exclusively on the tasks you can’t easily achieve with other packages, and assumes you can meet the `data` requirements and customize your plots with other packages such as base R, dplyr, and ggplot2. It forces you to learn or reuse your existing knowledge of other R packages and workflows. -- The Y API has a more complex but complete toolkit. It offers more + - The Y API has a more complex but complete toolkit. It offers more functions and arguments that wrap features from other packages to help you meet the `data` requirements and customize your plots directly with r2dii.plot. and ggplot2. It forces you to learn the @@ -109,7 +109,7 @@ These tables summarize the differences for users and developers of r2dii.plot: | | X API | Y API | -|:-----------------------------------------------|:--------------------|:----------------------------------------------| +| :--------------------------------------------- | :------------------ | :-------------------------------------------- | | Interface | Simpler | More complex | | Meet `data` requirements | With other packages | With r2dii.plot and optionally other packages | | Customize plots | With other packages | With r2dii.plot and optionally other packages | @@ -118,7 +118,7 @@ r2dii.plot: *The X and Y APIs compared from a user’s perspective.* | | X API | Y API | -|:-----------------|:------|:------| +| :--------------- | :---- | :---- | | Easy to maintain | Less | More | | Easy to extend | More | Less | @@ -132,7 +132,9 @@ API](https://2degreesinvesting.github.io/r2dii.plot/articles/articles/r2dii-plot articles. Notice the resulting plot is almost the same (except for the labels) but the toolkit is different. -- X API + - X API + + ``` r data <- market_share @@ -152,7 +154,9 @@ plot_trajectoryX(prep) + -- Y API + - Y API + + ``` r data <- market_share