Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display AE in 1 page #52

Merged
merged 7 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
}
```
````

Loading