Skip to content

Commit 6dc333a

Browse files
committed
add argument to customize filter label
1 parent 217216d commit 6dc333a

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: forestly
22
Title: Interactive Forest Plot
3-
Version: 0.1.1
3+
Version: 0.1.2
44
Authors@R: c(
55
person("Yilong", "Zhang", role = c("aut")),
66
person("Benjamin", "Wang", email = "[email protected]", role = c("aut", "cre")),
@@ -47,4 +47,4 @@ Suggests:
4747
VignetteBuilder: knitr
4848
Config/testthat/edition: 3
4949
Roxygen: list(markdown = TRUE)
50-
RoxygenNote: 7.3.1
50+
RoxygenNote: 7.3.2

R/ae_forestly.R

+12-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#' @param outdata An `outdata` object created by [format_ae_forestly()].
2222
#' @param display_soc_toggle A boolean value to display SOC toggle button.
2323
#' @param filter A character value of the filter variable.
24+
#' @param filter_label A character value of the label for slider bar.
2425
#' @param width A numeric value of width of the table in pixels.
2526
#' @param max_page A numeric value of max page number shown in the table.
2627
#'
@@ -44,11 +45,18 @@
4445
ae_forestly <- function(outdata,
4546
display_soc_toggle = TRUE,
4647
filter = c("prop", "n"),
48+
filter_label = NULL,
4749
width = 1400,
4850
max_page = NULL) {
4951
filter <- match.arg(filter)
5052
filter_range <- c(0, 100)
5153

54+
if(is.null(filter_label)) {
55+
filter_label <- ifelse(filter == "prop",
56+
"Incidence (%) in One or More Treatment Groups",
57+
"Number of AE in One or More Treatment Groups")
58+
}
59+
5260
# `max_page` controls the maximum page number displayed in the interactive forest table.
5361
# By default (`NULL`), it will display the counts that round up to the nearest hundred.
5462
if (is.null(max_page)) {
@@ -102,7 +110,7 @@ ae_forestly <- function(outdata,
102110
if (filter == "prop") {
103111
filter_subject <- crosstalk::filter_slider(
104112
id = "filter_subject",
105-
label = "Incidence (%) in One or More Treatment Groups",
113+
label = filter_label,
106114
sharedData = tbl,
107115
column = ~hide_prop, # whose values will be used for this slider
108116
step = 1, # specifies interval between each select-able value on the slider
@@ -115,13 +123,13 @@ ae_forestly <- function(outdata,
115123
if (filter == "n") {
116124
filter_subject <- crosstalk::filter_slider(
117125
id = "filter_subject",
118-
label = "Number of AE in One or More Treatment Groups",
126+
label = filter_label,
119127
sharedData = tbl,
120128
column = ~hide_n,
121129
step = 1,
122130
width = 250,
123-
min = filter_range[1],
124-
max = filter_range[2]
131+
min = filter_range[1], # the leftmost value of the slider
132+
max = filter_range[2] # the rightmost value of the slider
125133
)
126134
}
127135

man/ae_forestly.Rd

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

0 commit comments

Comments
 (0)