Validate that dataset has a minimum number of observations
validate_has_data.Rd
Arguments
- x
a data.frame
- min_nrow
minimum number of rows in
x
- complete
logical
defaultFALSE
when set toTRUE
then complete cases are checked.- allow_inf
logical
defaultTRUE
when set toFALSE
then error thrown if any values are infinite.- msg
(
character(1)
) additional message to display alongside the default message.
Examples
library(scda)
ADSL <- synthetic_cdisc_data("latest")$adsl
ui <- fluidPage(
sliderInput("obs", "Max Age",
min = 0, max = 100, value = 50
),
plotOutput("plot")
)
server <- function(input, output) {
output$plot <- renderPlot({
ADSL_f <- ADSL[ADSL$AGE <= input$obs, ]
validate_has_data(ADSL_f, min_nrow = 10, complete = FALSE, msg = "Please adjust your Max Age")
hist(ADSL_f$AGE, breaks = 5)
})
}
if (FALSE) {
shinyApp(ui, server)
}