1
ui <- fluidPage(

  # Application title
 # titlePanel("Old Faithful Geyser Data"),

    mainPanel(
     rHandsontableOutput('table'),
     br(),
     submitButton("Apply changes"),
     verbatimTextOutput('selected')
     )

)

 server <-  function(input, output) {
      data1 = read.csv("SampleCSVFile_2kb.csv", TRUE,",")


      output$table = renderRHandsontable(rhandsontable(data1, width = 1000, height = 250))

      output$selected=renderPrint({
        cat('\nChanged Cell Old Value:',input$table$changes$changes[[1]][[3]])
        cat('\nChanged Cell New Value:',input$table$changes$changes[[1]][[4]])
      })
    }

shinyApp(ui = ui, server = server)
4

1 回答 1

1

据我所知,当您按下提交按钮时,您希望访问服务器内的 rhandsontable 的输入。在下面的示例中,我修改了您的代码,以便在tableoutput.

library(shiny)
library(rhandsontable)

ui <- fluidPage(

  # Application title # titlePanel("Old Faithful Geyser Data"),

  mainPanel(
    rHandsontableOutput('table'),
    br(),
    submitButton("Apply changes"),
    verbatimTextOutput('selected'),
    ##The updated table output
    rHandsontableOutput('tableoutput')
  )
) 


server <- function(input, output) {
  data1 = read.csv("SampleCSVFile_2kb.csv", TRUE,",")


  output$table = renderRHandsontable(rhandsontable(data1, width = 1000, height = 250))

  output$selected=renderPrint({
    cat('\nChanged Cell Old Value:',input$table$changes$changes[[1]][[3]])
    cat('\nChanged Cell New Value:',input$table$changes$changes[[1]][[4]])
  })

   observe(
     if(!is.null(input$table)){
       output$tableoutput = renderRHandsontable(rhandsontable(hot_to_r(input$table), width = 1000, height = 250))


     }
   )

}


shinyApp(ui = ui, server = server)

希望能帮助到你!

于 2016-11-18T06:16:42.320 回答