Save input to .csv on submit - Click submit nothing happens, but not errors either...

Have a small dashboard.
When the submit button is clicked there is no error, but there's also nothing written to the file.

The code looks like this:


library(shiny)
library(shinydashboard)
library(googlesheets4)
library(markdown)
library(DT)
library(ggplot2)
library(plotly)
library(rmarkdown)
library(knitr)
library(pander)

# Load local test data

dbrp_data2 <- read.csv(file = 'location of locally stored .csv file')

# Define the fields we want to save from the form

# Dashboard page

ui <- dashboardPage(
    
    # Begin dashboard header
    dashboardHeader(title = "DBRP"),
    
    # Begin dashboard sidebar
    dashboardSidebar(
        
        # Begin sidebar menu
        sidebarMenu(
            menuItem("Artifact Entry", tabName = "artifactentry")
            # End sidebar menu
        )
        # End Dashboard sidebar
    ),
    
    # Begin dashboard body
    dashboardBody(
        
        # Begin tab items by tab name
        tabItems(
            
            # Begin first tab item
            tabItem(tabName = "artifactentry", h2("Artifact Entry"),
                    
                    # Begin first fluid row - artifact entry for submit and reset buttons
                    fluidRow(
                        
                        # Begin first box of first fluid row - artifact entry
                        box(h3("Submit or Reset Data"), width = 7,
                            
                            # Begin first column of first box of first fluid row - artifact entry
                            column(3, h4("Submit Data"),
                                   # Submit action button
                                   actionButton("submit_artifact_entry", label = "Submit")
                                   
                                   # End first column of first box of first fluid row - artifact entry
                            ),
                            
                            # Begin second column of first box of first fluid row - artifact entry
                            column(3, h4("Reset Entries"),
                                   # Reset action button
                                   actionButton("reset_artifact_entry", label = "Reset")
                                   
                                   # End second column of first box of first fluid row - artifact entry
                            )
                            
                            
                            # End first box of first tab item - artifact entry
                        )
                        
                        # End first fluid row - artifact entry for submit and reset buttons
                    ),
                    
                    # Begin second fluid row - widgets to test area
                    fluidRow(
                        
                        # Begin box of second fluidRow - widgets to test area
                        box(h3("Widgets to Test"),
                            
                            # Begin first column of second fluidRow - widgets to test
                            column(4, h4("Widgets"),
                                   
                                   # Checkbox widget to test
                                   checkboxGroupInput("dbir", selected = NULL,
                                                      h4("Select Rating"),
                                                      c(
                                                          "Low" = "Low",
                                                          "Medium" = "Medium",
                                                          "High" = "High",
                                                          "Critical" = "Critical"
                                                      )
                                                      # End checkbox widget to test
                                   )
                                   
                                   
                                   # End box of second fluidRow - widgets to test area
                            )
                            
                            # End box second fluidRow - widgets to test
                        )
                        
                        
                        
                        # End second fluidRow - widgets to test area
                    )
                    
                    
                    # End first tab item
            )
            

            
            # End tab items by tab name
        )

        # End dashboard body
    )
 
    
    # End dashboard page
)

# Begin server functions
server <- function(input, output, session) {
    
    # Rest button for artifact entry page
    observeEvent(input$reset_artifact_entry, {
        
        # Reset data breach rating check box
        updateCheckboxGroupInput(session, "dbir", choices = c(
            "Low" = "Low",
            "Medium" = "Medium",
            "High" = "High",
            "Critical" = "Critical"), selected = NULL)
    })

    observeEvent(input$submit_artifact_entry, {
        
        submit <- data.frame(dbir = input$dbir)
        
        
        # append write of data on submit
        write.table(submit, "dbrp_test_data2.csv",
                    append = TRUE,
                    col.names = FALSE
                    
        )
        
    })

    
    # End server functions
}


shinyApp(ui, server)

How do I get the value from the checkboxGroupInput into a file where the data appends every time i click submit?

I've gone to a couple of references and i'm now more confused than educated...sigh...

Cheers ~!

Is it possible that in making this example you inadvertently fixed your issue?
because I ran it, clicked some boxes, clicked submit, and a file was writ...

@nirgrahamuk

Hey Nir - I figured it out late yesterday.
App is now working exactly as intended.
Yea - some of it worked just fine I found like you did.
Also figured out how to remove the row.num from the csv as well.
I might add it back in, but most likely I'll leave that flagged as off -

As always - thanks for taking the time to look at my issue =)

Cheers ~!

1 Like