Arguments
- data
(
data.frame
)- varname
(
character(1)
) name of variable to check for indata
- msg
(
character(1)
) message to display ifdata
does not includevarname
Details
This function is a wrapper for shiny::validate
.
Examples
data <- data.frame(
one = rep("a", length.out = 20),
two = rep(c("a", "b"), length.out = 20)
)
ui <- fluidPage(
selectInput(
"var",
"Select variable",
choices = c("one", "two", "three", "four"),
selected = "one"
),
verbatimTextOutput("summary")
)
server <- function(input, output) {
output$summary <- renderText({
validate_has_variable(data, input$var)
paste0("Selected treatment variables: ", paste(input$var, collapse = ", "))
})
}
if (interactive()) {
shinyApp(ui, server)
}