Skip to contents

[Stable]

Usage

validate_no_intersection(x, y, msg)

Arguments

x

vector

y

vector

msg

message to display if x and y intersect

Examples

library(scda)
ADSL <- synthetic_cdisc_data("latest")$adsl

ui <- fluidPage(
  selectInput("ref_arm", "Select reference treatment",
    choices = c("ARM A", "ARM B", "ARM C"),
    selected = "ARM A"
  ),
  selectInput("comp_arm", "Select comparison treatment",
    choices = c("ARM A", "ARM B", "ARM C"),
    selected = "ARM C"
  ),
  verbatimTextOutput("arm_summary")
)

server <- function(input, output) {
  output$arm_summary <- renderText({
    ref_arm <- ADSL$ARMCD[input$ref_arm == ADSL$ARMCD]
    comp_arm <- ADSL$ARMCD[input$comp_arm == ADSL$ARMCD]

    validate_no_intersection(
      comp_arm, ref_arm,
      "reference and comparison treatments cannot overlap"
    )
    paste0(
      "Number of patients in: reference treatment=", length(ref_arm),
      " comparions treatment=", length(comp_arm)
    )
  })
}
if (FALSE) {
shinyApp(ui, server)
}