R 提交时将输入保存到.csv-单击“提交”不会发生任何事情,但也不会出现错误

R 提交时将输入保存到.csv-单击“提交”不会发生任何事情,但也不会出现错误,r,csv,shiny,save,action,R,Csv,Shiny,Save,Action,有一个小仪表盘。 单击submit按钮时没有错误,但也没有写入文件 代码如下所示: 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_dat

有一个小仪表盘。 单击submit按钮时没有错误,但也没有写入文件

代码如下所示:

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)
库(闪亮)
图书馆(shinydashboard)
图书馆(谷歌地图4)
图书馆(降价)
图书馆(DT)
图书馆(GG2)
图书馆(绘本)
图书馆(rmarkdown)
图书馆(knitr)
图书馆(潘德尔)
#加载本地测试数据

dbrp_data2我认为您的数据框“提交”必须首先是一个被动值或多个值的占位符

ui:
your part from above

server:
    submit <- reactiveValues()
    submit$some_variable_name<- data.frame(dbir = input$dbir)

    write.table(submit$some_variable_name, "dbrp_test_data2.csv",
                    append = TRUE,
                    col.names = FALSE                  
        )
ui:
你在上面的角色
服务器:

提交好的-我会很快尝试…应该很难将更改放入…好的-这样就行了-谢谢!我还必须在代码的write.table部分添加确切的文件路径现在我必须弄清楚如何在一次提交中使用大量输入来完成这项工作-如果您能将我的答案标记为正确并竖起大拇指,我将非常高兴!不客气!好吧-我想我做得对…对不起,我是斯塔克over系统的新手。