From 11d86f5650d95079757ba458b6ea1d464bf753c4 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Tue, 23 Jan 2024 17:01:06 +0100 Subject: [PATCH 01/10] add_fan() groups the legend when using `name` --- R/add_fan.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/R/add_fan.R b/R/add_fan.R index 462aeaf..dd7cf50 100644 --- a/R/add_fan.R +++ b/R/add_fan.R @@ -53,6 +53,9 @@ add_fan <- function( if (is.null(text)) { text <- ~hoverinfo } + if (!missing(name)) { + dots$legendgroup <- name + } for (prob in seq(max_prob, 1e-6, by = -step)) { dots$hoverinfo <- ifelse(prob < max_prob, "none", hoverinfo) dots$x <- x @@ -76,7 +79,8 @@ add_fan <- function( p |> add_ribbons( data = data, x = x, ymin = y, ymax = y, opacity = 1, showlegend = TRUE, - line = list(width = 0), fillcolor = fillcolor, name = name + line = list(width = 0), fillcolor = fillcolor, name = name, + legendgroup = name ) } From 7ec17e8a6c8f72fe6b98cb9c96f6761793e44c92 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Tue, 23 Jan 2024 17:02:43 +0100 Subject: [PATCH 02/10] bump package version --- DESCRIPTION | 4 ++-- NEWS.md | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ccde955..e0f7c50 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: effectclass Title: Classification and Visualisation of Effects -Version: 0.1.4 +Version: 0.1.5 Authors@R: c( person("Thierry", "Onkelinx", , "thierry.onkelinx@inbo.be", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-8804-4216", affiliation = "Research Institute for Nature and Forest (INBO)")), @@ -31,4 +31,4 @@ Config/checklist/keywords: classification; effect size; uncertainty; Encoding: UTF-8 Language: en-GB Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.0 diff --git a/NEWS.md b/NEWS.md index 285a71c..1139440 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# effectclass 0.1.5 + +* `add_fan()` groups the traces when setting `name`. + # effectclass 0.1.4 * `add_fan()`, `add_classification()`, `reference_shape()` and From 53e8cf0ec4c4833a56e0cb80c854fbf3a96f9c40 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Tue, 23 Jan 2024 17:03:09 +0100 Subject: [PATCH 03/10] update citation --- .zenodo.json | 2 +- CITATION.cff | 2 +- inst/CITATION | 6 +++--- organisation.yml | 13 +++++++++++++ 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 organisation.yml diff --git a/.zenodo.json b/.zenodo.json index 8fc9c47..32ee93a 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -1,6 +1,6 @@ { "title": "effectclass: Classification and Visualisation of Effects", - "version": "0.1.4", + "version": "0.1.5", "license": "GPL-3.0", "upload_type": "software", "description": "

Classify effects by comparing the confidence intervals with\nthresholds.<\/p>", diff --git a/CITATION.cff b/CITATION.cff index 57e8c74..9475c87 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -24,4 +24,4 @@ abstract: "Classify effects by comparing the confidence intervals with threshold identifiers: - type: url value: https://inbo.github.io/effectclass/ -version: 0.1.4 +version: 0.1.5 diff --git a/inst/CITATION b/inst/CITATION index 7a3ba57..ad8ea89 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -2,12 +2,12 @@ citHeader("To cite `effectclass` in publications please use:") # begin checklist entry bibentry( bibtype = "Manual", - title = "effectclass: Classification and Visualisation of Effects. Version 0.1.4", + title = "effectclass: Classification and Visualisation of Effects. Version 0.1.5", author = c( author = c(person(given = "Thierry", family = "Onkelinx"))), - year = 2023, + year = 2024, url = "https://inbo.github.io/effectclass/", abstract = "Classify effects by comparing the confidence intervals with thresholds.", - textVersion = "Onkelinx, Thierry (2023) effectclass: Classification and Visualisation of Effects. Version 0.1.4. https://inbo.github.io/effectclass/", + textVersion = "Onkelinx, Thierry (2024) effectclass: Classification and Visualisation of Effects. Version 0.1.5. https://inbo.github.io/effectclass/", keywords = "classification; effect size; uncertainty; visualisation", ) # end checklist entry diff --git a/organisation.yml b/organisation.yml new file mode 100644 index 0000000..cf69e43 --- /dev/null +++ b/organisation.yml @@ -0,0 +1,13 @@ +community: inbo +email: info@inbo.be +github: inbo +funder: Research Institute for Nature and Forest (INBO) +rightsholder: Research Institute for Nature and Forest (INBO) +organisation: + inbo.be: + affiliation: + - Research Institute for Nature and Forest (INBO) + - Instituut voor Natuur- en Bosonderzoek (INBO) + - Institut de Recherche sur la Nature et les Forêts (INBO) + - Institut für Natur- und Waldforschung (INBO) + orcid: yes From 963e42b7561f99d50c0c812e4d2f8d652ed8767a Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Wed, 24 Jan 2024 11:48:20 +0100 Subject: [PATCH 04/10] upgrade roxygen2 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index e0f7c50..dc4e8c4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,4 +31,4 @@ Config/checklist/keywords: classification; effect size; uncertainty; Encoding: UTF-8 Language: en-GB Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.0 +RoxygenNote: 7.3.1 From ac3a5b6233cd629d836e97429aeef42d74bfd521 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Wed, 24 Jan 2024 12:11:57 +0100 Subject: [PATCH 05/10] update checklist infrastructure --- .Rbuildignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.Rbuildignore b/.Rbuildignore index 1a54808..49e8ba8 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -14,6 +14,7 @@ ^data-raw$ ^docs$ ^man-roxygen$ +^organisation.yml$ ^pkgdown$ appveyor.yml tic.R From b7da20498db74b76930880a19d3800e1d9c96108 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Fri, 23 Feb 2024 11:08:38 +0100 Subject: [PATCH 06/10] set background of hover info of add_fan() to the fillcolor --- R/add_fan.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/add_fan.R b/R/add_fan.R index dd7cf50..e9b8fb1 100644 --- a/R/add_fan.R +++ b/R/add_fan.R @@ -57,7 +57,7 @@ add_fan <- function( dots$legendgroup <- name } for (prob in seq(max_prob, 1e-6, by = -step)) { - dots$hoverinfo <- ifelse(prob < max_prob, "none", hoverinfo) + dots$hoverinfo <- hoverinfo dots$x <- x dots$text <- text dots$ymin <- ~lcl @@ -67,6 +67,7 @@ add_fan <- function( dots$inherit <- TRUE dots$line <- list(width = 0) dots$fillcolor <- fillcolor + dots$color <- I(fillcolor) dots$p <- p dots$data <- error_ribbon( data = data, y = y, sd = sd, prob = prob, link = link From b57f686cf82afcbff45e5062a28a92948735e71c Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Wed, 28 Feb 2024 15:46:16 +0100 Subject: [PATCH 07/10] change_breaks() gains an extra argument --- R/change_breaks.R | 25 +++++++++++++++++++++---- man/change_breaks.Rd | 7 ++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/R/change_breaks.R b/R/change_breaks.R index 633c0ae..36c7afc 100644 --- a/R/change_breaks.R +++ b/R/change_breaks.R @@ -2,17 +2,23 @@ #' #' Breaks a set of pretty breaks for changes. #' @param n the number of breaks on either side of the reference +#' @param extra An optional vector of additional breaks. +#' The function always appends these breaks. +#' Use this option when you want to force this values to be a part of the +#' breaks. #' @export #' @importFrom assertthat assert_that is.count #' @importFrom utils head tail #' @family utils -change_breaks <- function(n = 2) { +change_breaks <- function(n = 2, extra = NULL) { assert_that(is.count(n)) n_default <- n - function(x, n = n_default) { + extra_default <- extra + function(x, n = n_default, extra = extra_default) { if (length(x) == 0) { return(numeric(0)) } + stopifnot(is.numeric(x)) abs(x) |> max() |> exp() -> extreme @@ -32,11 +38,22 @@ change_breaks <- function(n = 2) { rel_position <- log(candidate) / max(log(candidate)) seq(0, 1, length = n + 1) |> outer(rel_position, "-") -> delta - selected <- candidate[apply(delta ^ 2, 1, which.min)] + selected <- candidate[unique(apply(delta ^ 2, 1, which.min))] rev(1 / selected) |> head(-1) |> c(selected) |> - log() + log() -> breaks + if (is.null(extra)) { + return(breaks) + } + stopifnot(is.numeric(extra)) + outer(breaks, extra, "-") |> + abs() -> delta + to_replace <- which(delta < min(diff(breaks)) / 10, arr.ind = TRUE) + breaks[to_replace[, "row"]] <- extra[to_replace[, "col"]] + c(breaks, extra) |> + sort() |> + unique() } } diff --git a/man/change_breaks.Rd b/man/change_breaks.Rd index 1eee92c..a987d0c 100644 --- a/man/change_breaks.Rd +++ b/man/change_breaks.Rd @@ -4,10 +4,15 @@ \alias{change_breaks} \title{Logarithmic breaks for changes} \usage{ -change_breaks(n = 2) +change_breaks(n = 2, extra = NULL) } \arguments{ \item{n}{the number of breaks on either side of the reference} + +\item{extra}{An optional vector of additional breaks. +The function always appends these breaks. +Use this option when you want to force this values to be a part of the +breaks.} } \description{ Breaks a set of pretty breaks for changes. From 06aedd269a72204a89c00ef2ef71ea7cebd3159e Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Fri, 31 May 2024 15:17:08 +0200 Subject: [PATCH 08/10] change_breaks() displays fewer breaks --- R/change_breaks.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/change_breaks.R b/R/change_breaks.R index 36c7afc..8a176fe 100644 --- a/R/change_breaks.R +++ b/R/change_breaks.R @@ -49,7 +49,7 @@ change_breaks <- function(n = 2, extra = NULL) { stopifnot(is.numeric(extra)) outer(breaks, extra, "-") |> abs() -> delta - to_replace <- which(delta < min(diff(breaks)) / 10, arr.ind = TRUE) + to_replace <- which(delta < min(diff(breaks)) / 5, arr.ind = TRUE) breaks[to_replace[, "row"]] <- extra[to_replace[, "col"]] c(breaks, extra) |> sort() |> From 8b79330961649760e5eb011e3e65278ed9984b34 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Fri, 31 May 2024 15:17:18 +0200 Subject: [PATCH 09/10] update documentation --- man/stat_effect.Rd | 47 ++++++++++++++++++++++++++++++++++++++-------- man/stat_fan.Rd | 47 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 78 insertions(+), 16 deletions(-) diff --git a/man/stat_effect.Rd b/man/stat_effect.Rd index a5e9226..bb78271 100644 --- a/man/stat_effect.Rd +++ b/man/stat_effect.Rd @@ -45,10 +45,18 @@ the plot data. The return value must be a \code{data.frame}, and will be used as the layer data. A \code{function} can be created from a \code{formula} (e.g. \code{~ head(.x, 10)}).} -\item{position}{Position adjustment, either as a string naming the adjustment -(e.g. \code{"jitter"} to use \code{position_jitter}), or the result of a call to a -position adjustment function. Use the latter if you need to change the -settings of the adjustment.} +\item{position}{A position adjustment to use on the data for this layer. This +can be used in various ways, including to prevent overplotting and +improving the display. The \code{position} argument accepts the following: +\itemize{ +\item The result of calling a position function, such as \code{position_jitter()}. +This method allows for passing extra arguments to the position. +\item A string naming the position adjustment. To give the position as a +string, strip the function name of the \code{position_} prefix. For example, +to use \code{position_jitter()}, give the position as \code{"jitter"}. +\item For more information and other ways to specify the position, see the +\link[ggplot2:layer_positions]{layer position} documentation. +}} \item{na.rm}{If \code{FALSE}, the default, missing values are removed with a warning. If \code{TRUE}, missing values are silently removed.} @@ -64,10 +72,33 @@ rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.} -\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}. These are -often aesthetics, used to set an aesthetic to a fixed value, like -\code{colour = "red"} or \code{size = 3}. They may also be parameters -to the paired geom/stat.} +\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}'s \code{params} argument. These +arguments broadly fall into one of 4 categories below. Notably, further +arguments to the \code{position} argument, or aesthetics that are required +can \emph{not} be passed through \code{...}. Unknown arguments that are not part +of the 4 categories below are ignored. +\itemize{ +\item Static aesthetics that are not mapped to a scale, but are at a fixed +value and apply to the layer as a whole. For example, \code{colour = "red"} +or \code{linewidth = 3}. The geom's documentation has an \strong{Aesthetics} +section that lists the available options. The 'required' aesthetics +cannot be passed on to the \code{params}. Please note that while passing +unmapped aesthetics as vectors is technically possible, the order and +required length is not guaranteed to be parallel to the input data. +\item When constructing a layer using +a \verb{stat_*()} function, the \code{...} argument can be used to pass on +parameters to the \code{geom} part of the layer. An example of this is +\code{stat_density(geom = "area", outline.type = "both")}. The geom's +documentation lists which parameters it can accept. +\item Inversely, when constructing a layer using a +\verb{geom_*()} function, the \code{...} argument can be used to pass on parameters +to the \code{stat} part of the layer. An example of this is +\code{geom_area(stat = "density", adjust = 0.5)}. The stat's documentation +lists which parameters it can accept. +\item The \code{key_glyph} argument of \code{\link[ggplot2:layer]{layer()}} may also be passed on through +\code{...}. This can be one of the functions described as +\link[ggplot2:draw_key]{key glyphs}, to change the display of the layer in the legend. +}} \item{threshold}{A vector of either 1 or 2 thresholds. A single threshold will be transformed into diff --git a/man/stat_fan.Rd b/man/stat_fan.Rd index a2cc58b..955c21e 100644 --- a/man/stat_fan.Rd +++ b/man/stat_fan.Rd @@ -41,10 +41,18 @@ the plot data. The return value must be a \code{data.frame}, and will be used as the layer data. A \code{function} can be created from a \code{formula} (e.g. \code{~ head(.x, 10)}).} -\item{position}{Position adjustment, either as a string naming the adjustment -(e.g. \code{"jitter"} to use \code{position_jitter}), or the result of a call to a -position adjustment function. Use the latter if you need to change the -settings of the adjustment.} +\item{position}{A position adjustment to use on the data for this layer. This +can be used in various ways, including to prevent overplotting and +improving the display. The \code{position} argument accepts the following: +\itemize{ +\item The result of calling a position function, such as \code{position_jitter()}. +This method allows for passing extra arguments to the position. +\item A string naming the position adjustment. To give the position as a +string, strip the function name of the \code{position_} prefix. For example, +to use \code{position_jitter()}, give the position as \code{"jitter"}. +\item For more information and other ways to specify the position, see the +\link[ggplot2:layer_positions]{layer position} documentation. +}} \item{na.rm}{If \code{FALSE}, the default, missing values are removed with a warning. If \code{TRUE}, missing values are silently removed.} @@ -62,10 +70,33 @@ the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.} \item{geom}{Use a different \code{geom} than the default \code{"ribbon"}.} -\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}. These are -often aesthetics, used to set an aesthetic to a fixed value, like -\code{colour = "red"} or \code{size = 3}. They may also be parameters -to the paired geom/stat.} +\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}'s \code{params} argument. These +arguments broadly fall into one of 4 categories below. Notably, further +arguments to the \code{position} argument, or aesthetics that are required +can \emph{not} be passed through \code{...}. Unknown arguments that are not part +of the 4 categories below are ignored. +\itemize{ +\item Static aesthetics that are not mapped to a scale, but are at a fixed +value and apply to the layer as a whole. For example, \code{colour = "red"} +or \code{linewidth = 3}. The geom's documentation has an \strong{Aesthetics} +section that lists the available options. The 'required' aesthetics +cannot be passed on to the \code{params}. Please note that while passing +unmapped aesthetics as vectors is technically possible, the order and +required length is not guaranteed to be parallel to the input data. +\item When constructing a layer using +a \verb{stat_*()} function, the \code{...} argument can be used to pass on +parameters to the \code{geom} part of the layer. An example of this is +\code{stat_density(geom = "area", outline.type = "both")}. The geom's +documentation lists which parameters it can accept. +\item Inversely, when constructing a layer using a +\verb{geom_*()} function, the \code{...} argument can be used to pass on parameters +to the \code{stat} part of the layer. An example of this is +\code{geom_area(stat = "density", adjust = 0.5)}. The stat's documentation +lists which parameters it can accept. +\item The \code{key_glyph} argument of \code{\link[ggplot2:layer]{layer()}} may also be passed on through +\code{...}. This can be one of the functions described as +\link[ggplot2:draw_key]{key glyphs}, to change the display of the layer in the legend. +}} \item{link}{the link function to apply on the \code{y} before calculating the coverage intervals. From bce4e8f9a27dbc102d31af1b79cb51527c6f0021 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Fri, 31 May 2024 15:23:24 +0200 Subject: [PATCH 10/10] update citation --- .zenodo.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.zenodo.json b/.zenodo.json index 32ee93a..c858fe2 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -3,7 +3,7 @@ "version": "0.1.5", "license": "GPL-3.0", "upload_type": "software", - "description": "

Classify effects by comparing the confidence intervals with\nthresholds.<\/p>", + "description": "

Classify effects by comparing the confidence intervals with thresholds.<\/p>", "keywords": [ "classification", "effect size", @@ -17,11 +17,11 @@ "name": "Onkelinx, Thierry", "affiliation": "Research Institute for Nature and Forest (INBO)", "orcid": "0000-0001-8804-4216", - "type": "ContactPerson" + "type": "contactperson" }, { "name": "Research Institute for Nature and Forest (INBO)", - "type": "RightsHolder" + "type": "rightsholder" } ], "creators": [