我正在try 用R构建一个表单,一旦单击表单末尾的操作按钮,它将用于填充一个表.我还没有弄明白的是如何在表单中提取数据并将其添加到表中的新行.现在,它只是用表单中的任何内容不断更新第一行.我在这里复制了代码的一个简单版本:
#ui.r
library(shiny)
shinyUI(fluidPage(
# Application title
titlePanel("Test App"),
sidebarPanel(
numericInput("x", "Enter Value of X", 1),
numericInput("y", "Enter Value of Y", 1),
actionButton("add_data", "Add Data", width="100%")
),
mainPanel(
tableOutput("xy_Table")
)
)
)
#server.R
library(shiny)
library(tidyverse)
shinyServer(function(input, output) {
x <- vector("numeric")
y <- vector("numeric")
xyTable <- tibble(x, y)
e <- reactive(input$x)
f <- reactive(input$y)
eventReactive(input$add_data, {
xyTable %>% add_row(x=e(), y=f())
})
output$xy_Table <- renderTable({
xyTable
})
})
非常感谢你的帮助.