From 9b6f5c791aa14190b821dccb5628b1b50436edea Mon Sep 17 00:00:00 2001 From: Shuo Geng Date: Fri, 17 May 2024 10:18:44 -0400 Subject: [PATCH 1/6] Add Maximum Page Options --- vignettes/layout.Rmd | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vignettes/layout.Rmd b/vignettes/layout.Rmd index 1d01856..461352b 100644 --- a/vignettes/layout.Rmd +++ b/vignettes/layout.Rmd @@ -56,6 +56,19 @@ outdata |> ae_forestly() ``` +# Maximum Page Options + +By default, it will display the counts that rounding up to the nearest hundred displayed in the interactive forest table. +It can be adjusted by adding "max_page =xx" argument to ae_forestly() function. + +````{r} +outdata |> + format_ae_forestly() |> + ae_forestly(max_page=280) + +``` + + # Change color By default, forestly is using teal for treatment group and plum for control group. From 3612bb7c3286d8230f1aca72e9a72b334e80b3a0 Mon Sep 17 00:00:00 2001 From: Shuo Geng Date: Fri, 17 May 2024 11:41:52 -0400 Subject: [PATCH 2/6] Add max_page argument to control the max page number showed in the interactive forest table --- R/ae_forestly.R | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/R/ae_forestly.R b/R/ae_forestly.R index e829030..d3ae120 100644 --- a/R/ae_forestly.R +++ b/R/ae_forestly.R @@ -38,10 +38,20 @@ #' format_ae_forestly() |> #' ae_forestly() #' } -ae_forestly <- function(outdata, filter = c("prop", "n"), width = 1400) { +ae_forestly <- function(outdata, filter = c("prop", "n"), width = 1400, max_page=NULL) { filter <- match.arg(filter) filter_range <- c(0, 100) + # Add max_page option with default value = NULL, this argument can control the max page number displayed in the interactive forest table. + # By default will display the counts that rounding up to the nearest hundred. + + if(is.null(max_page)){ + max_page = if(max(attr(outdata$tbl$name, "n"))<=100) c(10,25,50,100) else c(10,25,50,100, ceiling(max(attr(outdata$tbl$name, "n"))/100)*100) + } else { + max_page = if (max_page<=100) c(10,25,50,100) else c(10,25,50,100,max_page) + } + + parameters <- unlist(strsplit(outdata$parameter, ";")) par_label <- vapply(parameters, function(x) metalite::collect_adam_mapping(outdata$meta, x)$label, @@ -179,6 +189,9 @@ ae_forestly <- function(outdata, filter = c("prop", "n"), width = 1400) { highlight = TRUE ) }, + + pageSizeOptions = max_page, + # Default sort variable defaultSorted = c("parameter", names(outdata$diff)), defaultSortOrder = "desc" From f51ea01fe2817f229bb4a4c6040c36224b4150f3 Mon Sep 17 00:00:00 2001 From: Shuo Geng Date: Fri, 17 May 2024 13:44:09 -0400 Subject: [PATCH 3/6] add @param section for new added max_page argument --- R/ae_forestly.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/ae_forestly.R b/R/ae_forestly.R index d3ae120..0607965 100644 --- a/R/ae_forestly.R +++ b/R/ae_forestly.R @@ -21,6 +21,7 @@ #' @param outdata An `outdata` object created by [format_ae_forestly()]. #' @param filter A character value of the filter variable. #' @param width A numeric value of width of the table in pixels. +#' @param max_page A numeric value of max page number showed in table. #' #' @return An AE forest plot saved as a `shiny.tag.list` object. #' From 3cda68aa7e2175cf3a3307893972ebb413d12294 Mon Sep 17 00:00:00 2001 From: Shuo Geng Date: Fri, 17 May 2024 14:16:52 -0400 Subject: [PATCH 4/6] update ae_forestly.Rd --- man/ae_forestly.Rd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/man/ae_forestly.Rd b/man/ae_forestly.Rd index 03bd816..049bccf 100644 --- a/man/ae_forestly.Rd +++ b/man/ae_forestly.Rd @@ -4,7 +4,7 @@ \alias{ae_forestly} \title{Display interactive forest plot} \usage{ -ae_forestly(outdata, filter = c("prop", "n"), width = 1400) +ae_forestly(outdata, filter = c("prop", "n"), width = 1400, max_page = NULL) } \arguments{ \item{outdata}{An \code{outdata} object created by \code{\link[=format_ae_forestly]{format_ae_forestly()}}.} @@ -12,6 +12,8 @@ ae_forestly(outdata, filter = c("prop", "n"), width = 1400) \item{filter}{A character value of the filter variable.} \item{width}{A numeric value of width of the table in pixels.} + +\item{max_page}{A numeric value of max page number showed in table.} } \value{ An AE forest plot saved as a \code{shiny.tag.list} object. From 79caa2ebe2795819469d9403c2bcd4e4ef045d63 Mon Sep 17 00:00:00 2001 From: Shuo Geng Date: Fri, 17 May 2024 14:40:28 -0400 Subject: [PATCH 5/6] fix typo --- vignettes/layout.Rmd | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vignettes/layout.Rmd b/vignettes/layout.Rmd index 461352b..037202f 100644 --- a/vignettes/layout.Rmd +++ b/vignettes/layout.Rmd @@ -61,14 +61,12 @@ outdata |> By default, it will display the counts that rounding up to the nearest hundred displayed in the interactive forest table. It can be adjusted by adding "max_page =xx" argument to ae_forestly() function. -````{r} +```{r} outdata |> format_ae_forestly() |> ae_forestly(max_page=280) - ``` - # Change color By default, forestly is using teal for treatment group and plum for control group. @@ -151,3 +149,4 @@ For example, in an R Markdown document, use: } ``` ```` + From 1d52ab470e746b60e3e104acd3d35affee7920aa Mon Sep 17 00:00:00 2001 From: Nan Xiao Date: Wed, 29 May 2024 21:31:46 -0400 Subject: [PATCH 6/6] Improve code and text style consistency --- R/ae_forestly.R | 17 +++++++---------- man/ae_forestly.Rd | 2 +- vignettes/layout.Rmd | 8 ++++---- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/R/ae_forestly.R b/R/ae_forestly.R index 7811427..63f9d5a 100644 --- a/R/ae_forestly.R +++ b/R/ae_forestly.R @@ -22,7 +22,7 @@ #' @param display_soc_toggle A boolean value to display SOC toggle button. #' @param filter A character value of the filter variable. #' @param width A numeric value of width of the table in pixels. -#' @param max_page A numeric value of max page number showed in table. +#' @param max_page A numeric value of max page number shown in the table. #' #' @return An AE forest plot saved as a `shiny.tag.list` object. #' @@ -45,21 +45,18 @@ ae_forestly <- function(outdata, display_soc_toggle = TRUE, filter = c("prop", "n"), width = 1400, - max_page=NULL) { - + max_page = NULL) { filter <- match.arg(filter) filter_range <- c(0, 100) - # Add max_page option with default value = NULL, this argument can control the max page number displayed in the interactive forest table. - # By default will display the counts that rounding up to the nearest hundred. - - if(is.null(max_page)){ - max_page = if(max(attr(outdata$tbl$name, "n"))<=100) c(10,25,50,100) else c(10,25,50,100, ceiling(max(attr(outdata$tbl$name, "n"))/100)*100) + # `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)) { + max_page <- if (max(attr(outdata$tbl$name, "n")) <= 100) c(10, 25, 50, 100) else c(10, 25, 50, 100, ceiling(max(attr(outdata$tbl$name, "n")) / 100) * 100) } else { - max_page = if (max_page<=100) c(10,25,50,100) else c(10,25,50,100,max_page) + max_page <- if (max_page <= 100) c(10, 25, 50, 100) else c(10, 25, 50, 100, max_page) } - parameters <- unlist(strsplit(outdata$parameter, ";")) par_label <- vapply(parameters, function(x) metalite::collect_adam_mapping(outdata$meta, x)$label, diff --git a/man/ae_forestly.Rd b/man/ae_forestly.Rd index e478832..e89ca2a 100644 --- a/man/ae_forestly.Rd +++ b/man/ae_forestly.Rd @@ -21,7 +21,7 @@ ae_forestly( \item{width}{A numeric value of width of the table in pixels.} -\item{max_page}{A numeric value of max page number showed in table.} +\item{max_page}{A numeric value of max page number shown in the table.} } \value{ An AE forest plot saved as a \code{shiny.tag.list} object. diff --git a/vignettes/layout.Rmd b/vignettes/layout.Rmd index 037202f..d7bfdb0 100644 --- a/vignettes/layout.Rmd +++ b/vignettes/layout.Rmd @@ -56,15 +56,15 @@ outdata |> ae_forestly() ``` -# Maximum Page Options +# Maximum page options -By default, it will display the counts that rounding up to the nearest hundred displayed in the interactive forest table. -It can be adjusted by adding "max_page =xx" argument to ae_forestly() function. +By default, it will display the counts that round up to the nearest hundred displayed in the interactive forest plot table. +This can be adjusted by using the `max_page` argument in `ae_forestly()`. ```{r} outdata |> format_ae_forestly() |> - ae_forestly(max_page=280) + ae_forestly(max_page = 280) ``` # Change color