Validate that dataset has a minimum number of observations
Source:R/validations.R
validate_has_data.Rd
Arguments
- x
(
data.frame
)- min_nrow
(
numeric(1)
) Minimum allowed number of rows inx
.- complete
(
logical(1)
) Flag specifying whether to check only complete cases. Defaults toFALSE
.- allow_inf
(
logical(1)
) Flag specifying whether to allow infinite values. Defaults toTRUE
.- 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({
iris_df <- iris[iris$Sepal.Length <= input$len, ]
validate_has_data(
iris_df,
min_nrow = 10,
complete = FALSE,
msg = "Please adjust Max Length of Sepal"
)
hist(iris_df$Sepal.Length, breaks = 5)
})
}
if (interactive()) {
shinyApp(ui, server)
}