创建一个表单,该表单使用R将观察结果添加到现有表中

创建一个表单,该表单使用R将观察结果添加到现有表中,r,csv,shiny,R,Csv,Shiny,我在装有Windows 8.1的PC上使用RStudio 0.98.953和R3.1.0 我试图使用shiny in R为许多用户创建一个表单,通过添加到现有的、最初为空的表来存储他们键入的信息。我已经看到了一些关于这个主题的问题,但是答案写得不清楚 我希望任何用户都能够使用多个textInput字段添加到表中,然后调用此表对这些信息进行编辑、更新,甚至绘制图表。具体来说,我希望输入转到两个位置:一个dataTableOutput用于在用户屏幕上显示,另一个csv文件供我随时访问。相反,data

我在装有Windows 8.1的PC上使用RStudio 0.98.953和R3.1.0

我试图使用shiny in R为许多用户创建一个表单,通过添加到现有的、最初为空的表来存储他们键入的信息。我已经看到了一些关于这个主题的问题,但是答案写得不清楚

我希望任何用户都能够使用多个textInput字段添加到表中,然后调用此表对这些信息进行编辑、更新,甚至绘制图表。具体来说,我希望输入转到两个位置:一个dataTableOutput用于在用户屏幕上显示,另一个csv文件供我随时访问。相反,dataTableOutput一次只显示一个条目(最新条目)。并且没有任何内容写入csv文件。我已经做了许多条目来测试它,但它总是失败。我已经尝试在创建用户data.table的代码中使用了observe和isolation。我尝试了一个类似于
if(input$Submit>0){…
的if语句来使用Submit按钮,但是如果没有这个代码,Submit按钮似乎可以正常工作

这是我的代码:

服务器.R

library(data.table)

# first I initialize an empty data table with all of the potential fields 
# I want for each future record. There are more fields initially set than my user 
# will start off with.

ir <- data.table(X = "", Y = "", Z = "", W = "", V = "", U = "")

shinyServer(function(input, output) {

# this is a reactive data.table that takes inputs from the UI (X, Y, and Z).

obs <- reactive({

        data.table(X = input$X, Y = input$Y, 
                         Z = input$Z)
})

# this generates a table of the information for the user to see. It should show
# their record being added to a list that is continuously being added to. 

output$table <- renderDataTable({

    rbind(ir, obs())

    })

# take the latest entry, add it to the running table, and write to a csv.

reactive({
        rbind(ir, obs())
        write.csv(ir, file = "C:/Users/Geo/Documents/ideaTracker/data/ideaRecords.csv")
})
我认为许多其他人可以从这个问题(希望答案)的详细记录中获益

shinyUI(navbarPage("Tracker",

# some UI code is not shown since it only defines the layout of other pages in the app.

sidebarPanel(

    # This defines the 'X' input

    dateInput("X", label = h4("Date"), value = as.character(Sys.Date()), 
                          format = "mm/dd/yy"),

    # defines the 'Y' input

    textInput("Y", h4("Name"),
                          value = "Joe Employee"),

    # and the 'Z' input

    textInput("Z", h4("Enter Information Here"), value = ""),

    submitButton("Submit")
            ),

    mainPanel(

        # displays the information entered by the user and should show the 
        # running list with all previous entries.

        dataTableOutput("table"),

    )