- )
- } else {
- output$data_plot <- renderPlot(
- plot(NULL, xlim = c(0, 10), ylim = c(0, 10),
- xlab = input$data_units, ylab = "Cases", cex.lab = 1.5
- )
- )
- }
- })
-}
-
-# Add a single dataset to the existing table.
-single_entry <- function(input, output, react_values) {
- observeEvent(input$data_single, {
- valid <- TRUE
-
- # Ensure the dataset name is neither blank nor a duplicate.
- name <- trimws(input$data_name)
- if (name == "") {
- output$data_name_warn <- renderText("The dataset name cannot be blank.")
- valid <- FALSE
- } else if (name %in% react_values$data_table[, 1]) {
- output$data_name_warn <- renderText(
- "There is already a dataset with the specified name."
- )
- valid <- FALSE
- } else {
- output$data_name_warn <- renderText("")
- }
-
- # Ensure the case counts are specified as a comma-separated of one or more
- # non-negative integers.
- counts <- tokenize_counts(input$data_counts)
- if (length(counts) == 0) {
- output$data_counts_warn <- renderText("Case counts cannot be blank.")
- valid <- FALSE
- } else if (anyNA(counts) || any(counts < 0)) {
- output$data_counts_warn <- renderText(
- "Case counts can only contain non-negative integers."
- )
- valid <- FALSE
- } else {
- output$data_counts_warn <- renderText("")