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.
Details
This function is a wrapper for shiny::validate
.
Examples
library(teal)
ui <- fluidPage(
sliderInput("len", "Max Length of Sepal",
min = 4.3, max = 7.9, value = 5
),
plotOutput("plot")
)
server <- function(input, output) {
output$plot <- renderPlot({
df <- iris[iris$Sepal.Length <= input$len, ]
validate_has_data(
iris_f,
min_nrow = 10,
complete = FALSE,
msg = "Please adjust Max Length of Sepal"
)
hist(iris_f$Sepal.Length, breaks = 5)
})
}
if (interactive()) {
shinyApp(ui, server)
}