Skip to content

Commit

Permalink
Merge pull request #52 from Merck/displayAEin1Page
Browse files Browse the repository at this point in the history
Display AE in 1 page
  • Loading branch information
nanxstats authored May 30, 2024
2 parents fcaccdb + 1d52ab4 commit acbf106
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
16 changes: 15 additions & 1 deletion R/ae_forestly.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +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 shown in the table.
#'
#' @return An AE forest plot saved as a `shiny.tag.list` object.
#'
Expand All @@ -39,13 +40,23 @@
#' format_ae_forestly() |>
#' ae_forestly()
#' }

ae_forestly <- function(outdata,
display_soc_toggle = TRUE,
filter = c("prop", "n"),
width = 1400) {
width = 1400,
max_page = NULL) {
filter <- match.arg(filter)
filter_range <- c(0, 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)
}

parameters <- unlist(strsplit(outdata$parameter, ";"))
par_label <- vapply(parameters,
function(x) metalite::collect_adam_mapping(outdata$meta, x)$label,
Expand Down Expand Up @@ -185,6 +196,9 @@ ae_forestly <- function(outdata,
highlight = TRUE
)
},

pageSizeOptions = max_page,

# Default sort variable
defaultSorted = c("parameter", names(outdata$diff)),
defaultSortOrder = "desc"
Expand Down
5 changes: 4 additions & 1 deletion man/ae_forestly.Rd

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

12 changes: 12 additions & 0 deletions vignettes/layout.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ outdata |>
ae_forestly()
```

# Maximum page options

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)
```

# Change color

By default, forestly is using teal for treatment group and plum for control group.
Expand Down Expand Up @@ -138,3 +149,4 @@ For example, in an R Markdown document, use:
}
```
````

0 comments on commit acbf106

Please sign in to comment.