Skip to content

Commit

Permalink
Merge pull request #17 from inbo/plotly
Browse files Browse the repository at this point in the history
Plotly
  • Loading branch information
ThierryO authored Jun 4, 2024
2 parents fa43240 + bce4e8f commit a7aa52c
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 33 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
^data-raw$
^docs$
^man-roxygen$
^organisation.yml$
^pkgdown$
appveyor.yml
tic.R
8 changes: 4 additions & 4 deletions .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"title": "effectclass: Classification and Visualisation of Effects",
"version": "0.1.4",
"version": "0.1.5",
"license": "GPL-3.0",
"upload_type": "software",
"description": "<p>Classify effects by comparing the confidence intervals with\nthresholds.<\/p>",
"description": "<p>Classify effects by comparing the confidence intervals with thresholds.<\/p>",
"keywords": [
"classification",
"effect size",
Expand All @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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)")),
Expand Down Expand Up @@ -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.1
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 7 additions & 2 deletions R/add_fan.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ 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$hoverinfo <- hoverinfo
dots$x <- x
dots$text <- text
dots$ymin <- ~lcl
Expand All @@ -64,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
Expand All @@ -76,7 +80,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
)
}

Expand Down
25 changes: 21 additions & 4 deletions R/change_breaks.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)) / 5, arr.ind = TRUE)
breaks[to_replace[, "row"]] <- extra[to_replace[, "col"]]
c(breaks, extra) |>
sort() |>
unique()
}
}

Expand Down
6 changes: 3 additions & 3 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 additions & 1 deletion man/change_breaks.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 39 additions & 8 deletions man/stat_effect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 39 additions & 8 deletions man/stat_fan.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions organisation.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a7aa52c

Please sign in to comment.