Validates that dataset contains specific variable
validate_has_variable.Rd
Arguments
- data
a data.frame
- varname
name of variable in
data
- msg
message to display if
data
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)
}