Skip to content

Commit a7aa52c

Browse files
authored
Merge pull request #17 from inbo/plotly
Plotly
2 parents fa43240 + bce4e8f commit a7aa52c

12 files changed

+140
-33
lines changed

.Rbuildignore

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
^data-raw$
1515
^docs$
1616
^man-roxygen$
17+
^organisation.yml$
1718
^pkgdown$
1819
appveyor.yml
1920
tic.R

.zenodo.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"title": "effectclass: Classification and Visualisation of Effects",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"license": "GPL-3.0",
55
"upload_type": "software",
6-
"description": "<p>Classify effects by comparing the confidence intervals with\nthresholds.<\/p>",
6+
"description": "<p>Classify effects by comparing the confidence intervals with thresholds.<\/p>",
77
"keywords": [
88
"classification",
99
"effect size",
@@ -17,11 +17,11 @@
1717
"name": "Onkelinx, Thierry",
1818
"affiliation": "Research Institute for Nature and Forest (INBO)",
1919
"orcid": "0000-0001-8804-4216",
20-
"type": "ContactPerson"
20+
"type": "contactperson"
2121
},
2222
{
2323
"name": "Research Institute for Nature and Forest (INBO)",
24-
"type": "RightsHolder"
24+
"type": "rightsholder"
2525
}
2626
],
2727
"creators": [

CITATION.cff

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ abstract: "Classify effects by comparing the confidence intervals with threshold
2424
identifiers:
2525
- type: url
2626
value: https://inbo.github.io/effectclass/
27-
version: 0.1.4
27+
version: 0.1.5

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: effectclass
33
Title: Classification and Visualisation of Effects
4-
Version: 0.1.4
4+
Version: 0.1.5
55
Authors@R: c(
66
person("Thierry", "Onkelinx", , "thierry.onkelinx@inbo.be", role = c("aut", "cre"),
77
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;
3131
Encoding: UTF-8
3232
Language: en-GB
3333
Roxygen: list(markdown = TRUE)
34-
RoxygenNote: 7.2.3
34+
RoxygenNote: 7.3.1

NEWS.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# effectclass 0.1.5
2+
3+
* `add_fan()` groups the traces when setting `name`.
4+
15
# effectclass 0.1.4
26

37
* `add_fan()`, `add_classification()`, `reference_shape()` and

R/add_fan.R

+7-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ add_fan <- function(
5353
if (is.null(text)) {
5454
text <- ~hoverinfo
5555
}
56+
if (!missing(name)) {
57+
dots$legendgroup <- name
58+
}
5659
for (prob in seq(max_prob, 1e-6, by = -step)) {
57-
dots$hoverinfo <- ifelse(prob < max_prob, "none", hoverinfo)
60+
dots$hoverinfo <- hoverinfo
5861
dots$x <- x
5962
dots$text <- text
6063
dots$ymin <- ~lcl
@@ -64,6 +67,7 @@ add_fan <- function(
6467
dots$inherit <- TRUE
6568
dots$line <- list(width = 0)
6669
dots$fillcolor <- fillcolor
70+
dots$color <- I(fillcolor)
6771
dots$p <- p
6872
dots$data <- error_ribbon(
6973
data = data, y = y, sd = sd, prob = prob, link = link
@@ -76,7 +80,8 @@ add_fan <- function(
7680
p |>
7781
add_ribbons(
7882
data = data, x = x, ymin = y, ymax = y, opacity = 1, showlegend = TRUE,
79-
line = list(width = 0), fillcolor = fillcolor, name = name
83+
line = list(width = 0), fillcolor = fillcolor, name = name,
84+
legendgroup = name
8085
)
8186
}
8287

R/change_breaks.R

+21-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@
22
#'
33
#' Breaks a set of pretty breaks for changes.
44
#' @param n the number of breaks on either side of the reference
5+
#' @param extra An optional vector of additional breaks.
6+
#' The function always appends these breaks.
7+
#' Use this option when you want to force this values to be a part of the
8+
#' breaks.
59
#' @export
610
#' @importFrom assertthat assert_that is.count
711
#' @importFrom utils head tail
812
#' @family utils
9-
change_breaks <- function(n = 2) {
13+
change_breaks <- function(n = 2, extra = NULL) {
1014
assert_that(is.count(n))
1115
n_default <- n
12-
function(x, n = n_default) {
16+
extra_default <- extra
17+
function(x, n = n_default, extra = extra_default) {
1318
if (length(x) == 0) {
1419
return(numeric(0))
1520
}
21+
stopifnot(is.numeric(x))
1622
abs(x) |>
1723
max() |>
1824
exp() -> extreme
@@ -32,11 +38,22 @@ change_breaks <- function(n = 2) {
3238
rel_position <- log(candidate) / max(log(candidate))
3339
seq(0, 1, length = n + 1) |>
3440
outer(rel_position, "-") -> delta
35-
selected <- candidate[apply(delta ^ 2, 1, which.min)]
41+
selected <- candidate[unique(apply(delta ^ 2, 1, which.min))]
3642
rev(1 / selected) |>
3743
head(-1) |>
3844
c(selected) |>
39-
log()
45+
log() -> breaks
46+
if (is.null(extra)) {
47+
return(breaks)
48+
}
49+
stopifnot(is.numeric(extra))
50+
outer(breaks, extra, "-") |>
51+
abs() -> delta
52+
to_replace <- which(delta < min(diff(breaks)) / 5, arr.ind = TRUE)
53+
breaks[to_replace[, "row"]] <- extra[to_replace[, "col"]]
54+
c(breaks, extra) |>
55+
sort() |>
56+
unique()
4057
}
4158
}
4259

inst/CITATION

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ citHeader("To cite `effectclass` in publications please use:")
22
# begin checklist entry
33
bibentry(
44
bibtype = "Manual",
5-
title = "effectclass: Classification and Visualisation of Effects. Version 0.1.4",
5+
title = "effectclass: Classification and Visualisation of Effects. Version 0.1.5",
66
author = c( author = c(person(given = "Thierry", family = "Onkelinx"))),
7-
year = 2023,
7+
year = 2024,
88
url = "https://inbo.github.io/effectclass/",
99
abstract = "Classify effects by comparing the confidence intervals with thresholds.",
10-
textVersion = "Onkelinx, Thierry (2023) effectclass: Classification and Visualisation of Effects. Version 0.1.4. https://inbo.github.io/effectclass/",
10+
textVersion = "Onkelinx, Thierry (2024) effectclass: Classification and Visualisation of Effects. Version 0.1.5. https://inbo.github.io/effectclass/",
1111
keywords = "classification; effect size; uncertainty; visualisation",
1212
)
1313
# end checklist entry

man/change_breaks.Rd

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/stat_effect.Rd

+39-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/stat_fan.Rd

+39-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

organisation.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
community: inbo
2+
email: info@inbo.be
3+
github: inbo
4+
funder: Research Institute for Nature and Forest (INBO)
5+
rightsholder: Research Institute for Nature and Forest (INBO)
6+
organisation:
7+
inbo.be:
8+
affiliation:
9+
- Research Institute for Nature and Forest (INBO)
10+
- Instituut voor Natuur- en Bosonderzoek (INBO)
11+
- Institut de Recherche sur la Nature et les Forêts (INBO)
12+
- Institut für Natur- und Waldforschung (INBO)
13+
orcid: yes

0 commit comments

Comments
 (0)