validate_one_row_per_id {teal}R Documentation

Validate that dataset has unique rows for key variables

Description

[Stable]

Usage

validate_one_row_per_id(x, key = c("USUBJID", "STUDYID"))

Arguments

x

(data.frame)

key

(character) Vector of ID variables from x that identify unique records.

Details

This function is a wrapper for shiny::validate.

Examples

iris$id <- rep(1:50, times = 3)
ui <- fluidPage(
  selectInput(
    inputId = "species",
    label = "Select species",
    choices = c("setosa", "versicolor", "virginica"),
    selected = "setosa",
    multiple = TRUE
  ),
  plotOutput("plot")
)
server <- function(input, output) {
  output$plot <- renderPlot({
    iris_f <- iris[iris$Species %in% input$species, ]
    validate_one_row_per_id(iris_f, key = c("id"))

    hist(iris_f$Sepal.Length, breaks = 5)
  })
}
if (interactive()) {
  shinyApp(ui, server)
}


[Package teal version 0.15.2 Index]