Skip to content

Commit

Permalink
add argument to customize filter label
Browse files Browse the repository at this point in the history
  • Loading branch information
wangben718 committed Jan 8, 2025
1 parent 217216d commit 6dc333a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: forestly
Title: Interactive Forest Plot
Version: 0.1.1
Version: 0.1.2
Authors@R: c(
person("Yilong", "Zhang", role = c("aut")),
person("Benjamin", "Wang", email = "[email protected]", role = c("aut", "cre")),
Expand Down Expand Up @@ -47,4 +47,4 @@ Suggests:
VignetteBuilder: knitr
Config/testthat/edition: 3
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
16 changes: 12 additions & 4 deletions R/ae_forestly.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#' @param outdata An `outdata` object created by [format_ae_forestly()].
#' @param display_soc_toggle A boolean value to display SOC toggle button.
#' @param filter A character value of the filter variable.
#' @param filter_label A character value of the label for slider bar.
#' @param width A numeric value of width of the table in pixels.
#' @param max_page A numeric value of max page number shown in the table.
#'
Expand All @@ -44,11 +45,18 @@
ae_forestly <- function(outdata,
display_soc_toggle = TRUE,
filter = c("prop", "n"),
filter_label = NULL,
width = 1400,
max_page = NULL) {
filter <- match.arg(filter)
filter_range <- c(0, 100)

if(is.null(filter_label)) {
filter_label <- ifelse(filter == "prop",
"Incidence (%) in One or More Treatment Groups",
"Number of AE in One or More Treatment Groups")
}

# `max_page` controls the maximum page number displayed in the interactive forest table.
# By default (`NULL`), it will display the counts that round up to the nearest hundred.
if (is.null(max_page)) {
Expand Down Expand Up @@ -102,7 +110,7 @@ ae_forestly <- function(outdata,
if (filter == "prop") {
filter_subject <- crosstalk::filter_slider(
id = "filter_subject",
label = "Incidence (%) in One or More Treatment Groups",
label = filter_label,
sharedData = tbl,
column = ~hide_prop, # whose values will be used for this slider
step = 1, # specifies interval between each select-able value on the slider
Expand All @@ -115,13 +123,13 @@ ae_forestly <- function(outdata,
if (filter == "n") {
filter_subject <- crosstalk::filter_slider(
id = "filter_subject",
label = "Number of AE in One or More Treatment Groups",
label = filter_label,
sharedData = tbl,
column = ~hide_n,
step = 1,
width = 250,
min = filter_range[1],
max = filter_range[2]
min = filter_range[1], # the leftmost value of the slider
max = filter_range[2] # the rightmost value of the slider
)
}

Expand Down
3 changes: 3 additions & 0 deletions man/ae_forestly.Rd

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

0 comments on commit 6dc333a

Please sign in to comment.