Skip to content

Commit

Permalink
few enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelru committed Jan 24, 2024
1 parent 063ae3e commit dfc4e77
Show file tree
Hide file tree
Showing 20 changed files with 152 additions and 175 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.0
7 changes: 1 addition & 6 deletions R/teal_goshawk.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@
#' The data used for teal.goshawk have some constraints.
#' It must contain the columns `AVISITCD`, `BASE`, `BASE2`, `AVALU`, `LBSTRESC`, `LOQFL`, `CHG2`, and `PCHG2`.
#'
#' @docType package
#'
#' @name teal_goshawk
#'
#' @import goshawk
#' @import shiny
#' @import teal
#' @import teal.transform
#' @importFrom ggplot2 ggplot
#' @importFrom rlang .data sym
#' @importFrom teal.transform choices_selected
#' @keywords internal
NULL
"_PACKAGE"
11 changes: 5 additions & 6 deletions R/tm_g_gh_boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#' @export
#'
#' @examples
#'
#' # Example using ADaM structure analysis dataset.
#' data <- teal_data()
#' data <- within(data, {
Expand All @@ -60,8 +59,8 @@
#' "C: Combination" = "Combination"
#' )
#' set.seed(1)
#' ADSL <- goshawk::rADSL
#' ADLB <- goshawk::rADLB
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' dplyr::mutate(
Expand Down Expand Up @@ -117,10 +116,10 @@
#'
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- teal::init(
#' app <- init(
#' data = data,
#' modules = teal::modules(
#' teal.goshawk::tm_g_gh_boxplot(
#' modules = modules(
#' tm_g_gh_boxplot(
#' label = "Box Plot",
#' dataname = "ADLB",
#' param_var = "PARAMCD",
Expand Down
11 changes: 5 additions & 6 deletions R/tm_g_gh_correlationplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
#' @author Balazs Toth (tothb2) [email protected]
#'
#' @examples
#'
#' # Example using ADaM structure analysis dataset.
#' data <- teal_data()
#' data <- within(data, {
Expand All @@ -65,8 +64,8 @@
#' shape_manual <- c("N" = 1, "Y" = 2, "NA" = 0)
#'
#' set.seed(1)
#' ADSL <- goshawk::rADSL
#' ADLB <- goshawk::rADLB
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' dplyr::mutate(AVISITCD = dplyr::case_when(
Expand Down Expand Up @@ -139,10 +138,10 @@
#'
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- teal::init(
#' app <- init(
#' data = data,
#' modules = teal::modules(
#' teal.goshawk::tm_g_gh_correlationplot(
#' modules = modules(
#' tm_g_gh_correlationplot(
#' label = "Correlation Plot",
#' dataname = "ADLB",
#' param_var = "PARAMCD",
Expand Down
11 changes: 5 additions & 6 deletions R/tm_g_gh_density_distribution_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#' @export
#'
#' @examples
#'
#' # Example using ADaM structure analysis dataset.
#' data <- teal_data()
#' data <- within(data, {
Expand All @@ -44,8 +43,8 @@
#' "B: Placebo" = "Placebo",
#' "C: Combination" = "Combination"
#' )
#' ADSL <- goshawk::rADSL
#' ADLB <- goshawk::rADLB
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' dplyr::mutate(
Expand Down Expand Up @@ -81,10 +80,10 @@
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- teal::init(
#' app <- init(
#' data = data,
#' modules = teal::modules(
#' teal.goshawk::tm_g_gh_density_distribution_plot(
#' modules = modules(
#' tm_g_gh_density_distribution_plot(
#' label = "Density Distribution Plot",
#' dataname = "ADLB",
#' param_var = "PARAMCD",
Expand Down
11 changes: 5 additions & 6 deletions R/tm_g_gh_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#' @export
#'
#' @examples
#'
#' # Example using ADaM structure analysis dataset.
#' data <- teal_data()
#' data <- within(data, {
Expand All @@ -66,8 +65,8 @@
#' "C: Combination" = "Combination"
#' )
#'
#' ADSL <- goshawk::rADSL
#' ADLB <- goshawk::rADLB
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' dplyr::mutate(
Expand Down Expand Up @@ -102,10 +101,10 @@
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- teal::init(
#' app <- init(
#' data = data,
#' modules = teal::modules(
#' teal.goshawk::tm_g_gh_lineplot(
#' modules = modules(
#' tm_g_gh_lineplot(
#' label = "Line Plot",
#' dataname = "ADLB",
#' param_var = "PARAMCD",
Expand Down
11 changes: 5 additions & 6 deletions R/tm_g_gh_scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#' @author Balazs Toth (tothb2) [email protected]
#'
#' @examples
#'
#' # Example using ADaM structure analysis dataset.
#' data <- teal_data()
#' data <- within(data, {
Expand All @@ -49,8 +48,8 @@
#' "C: Combination" = "Combination"
#' )
#'
#' ADSL <- goshawk::rADSL
#' ADLB <- goshawk::rADLB
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' dplyr::mutate(
Expand Down Expand Up @@ -86,10 +85,10 @@
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#'
#' app <- teal::init(
#' app <- init(
#' data = data,
#' modules = teal::modules(
#' teal.goshawk::tm_g_gh_scatterplot(
#' modules = modules(
#' tm_g_gh_scatterplot(
#' label = "Scatter Plot",
#' dataname = "ADLB",
#' param_var = "PARAMCD",
Expand Down
11 changes: 5 additions & 6 deletions R/tm_g_gh_spaghettiplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
#' @export
#'
#' @examples
#'
#' # Example using ADaM structure analysis dataset.
#' data <- teal_data()
#' data <- within(data, {
Expand All @@ -68,8 +67,8 @@
#' "C: Combination" = "Combination"
#' )
#' set.seed(1)
#' ADSL <- goshawk::rADSL
#' ADLB <- goshawk::rADLB
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' dplyr::mutate(
Expand Down Expand Up @@ -121,10 +120,10 @@
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- teal::init(
#' app <- init(
#' data = data,
#' modules = teal::modules(
#' teal.goshawk::tm_g_gh_spaghettiplot(
#' modules = modules(
#' tm_g_gh_spaghettiplot(
#' label = "Spaghetti Plot",
#' dataname = "ADLB",
#' param_var = "PARAMCD",
Expand Down
65 changes: 26 additions & 39 deletions R/toggleable_slider.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,34 @@
#' @examples
#' value <- c(20.3, 81.5) # dichotomous slider
#' # value <- c(50.1) # normal slider
#' app <- shinyApp(
#' ui = div(
#' teal.goshawk:::toggle_slider_ui(
#' "toggle_slider", "Select value",
#' min = 0.2, max = 100.1, value = value,
#' slider_initially = FALSE, step_slider = 0.1, step_numeric = 0.001
#' ),
#' verbatimTextOutput("value")
#' ),
#' server = function(input, output, session) {
#' is_dichotomous_slider <- (length(value) == 2)
#' range_value <- toggle_slider_server("toggle_slider",
#' is_dichotomous_slider = is_dichotomous_slider
#' )
#' messages <- reactiveVal() # to keep history
#' observeEvent(range_value$state(), {
#' list_with_names_str <- function(x) paste(names(x), x, sep = ": ", collapse = ", ")
#' messages(c(messages(), list_with_names_str(range_value$state())))
#' })
#' output$value <- renderText({
#' paste(messages(), collapse = "\n")
#' })
#'
#' # for stress-testing example, update slider settings
#' # bug with invalidateLater not working inside `observeEvent`
#' # observe({
#' # invalidateLater(1000, session)
#' # a <- sample(0:100, 1) # for range
#' # b <- sample(0:100, 1)
#' # isolate(do.call(
#' # range_value$update_state,
#' # list(
#' # value = sort(sample(0:100, if (is_dichotomous_slider) 2 else 1)),
#' # min = min(a, b), max = max(a, b),
#' # step = sample(1:20, 1) / 10
#' # )[sample(1:4, sample(4, 1))] # select up to four fields from the list
#' # ))
#' # })
#' }
#' ui <- div(
#' teal.goshawk:::toggle_slider_ui(
#' "toggle_slider", "Select value",
#' min = 0.2, max = 100.1, value = value,
#' slider_initially = FALSE, step_slider = 0.1, step_numeric = 0.001
#' ),
#' verbatimTextOutput("value")
#' )
#' shinyApp(app$ui, app$server) %>% invisible()
#'
#' server <- function(input, output, session) {
#' is_dichotomous_slider <- (length(value) == 2)
#' range_value <- toggle_slider_server("toggle_slider",
#' is_dichotomous_slider = is_dichotomous_slider
#' )
#' messages <- reactiveVal() # to keep history
#' observeEvent(range_value$state(), {
#' list_with_names_str <- function(x) paste(names(x), x, sep = ": ", collapse = ", ")
#' messages(c(messages(), list_with_names_str(range_value$state())))
#' })
#' output$value <- renderText({
#' paste(messages(), collapse = "\n")
#' })
#' }
#'
#' if (interactive()) {
#' shinyApp(ui, server)
#' }
toggle_slider_ui <- function(id,
label,
min,
Expand Down
3 changes: 1 addition & 2 deletions R/utils-maptrt.r
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
#' @export
#'
#' @examples
#'
#' ADSL <- goshawk::rADSL
#' ADSL <- rADSL
#'
#' # get treatment mapping code
#' maptrt(df_armvar = ADSL$ARMCD, code = "M")
Expand Down
3 changes: 1 addition & 2 deletions man/maptrt.Rd

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

36 changes: 36 additions & 0 deletions man/teal.goshawk-package.Rd

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

14 changes: 0 additions & 14 deletions man/teal_goshawk.Rd

This file was deleted.

Loading

0 comments on commit dfc4e77

Please sign in to comment.