【发布时间】:2016-06-20 16:58:15
【问题描述】:
我有一个在 R ShinyTable 中渲染的 R 数据框。 ShinyTable 中的编辑工作正常。
我的问题是:如何获取用户所做的编辑并更新我的数据框。
以下代码取自 ShinyTable 的教程网站。它有一个错误:“尝试访问已弃用的 Shinysession$session 对象。请直接访问 Shinysession 对象。”但是代码中没有任何内容引用shinySession。
如果我能在回答我的主要问题(如何接受用户所做的编辑)方面获得帮助,我可以绕过这个错误。
library(shiny)
library(shinyTable)
server <- function(input, output, session) {
rv <- reactiveValues(cachedTbl = NULL)
output$tbl <- renderHtable({
if (is.null(input$tbl)){
tbl <- matrix(0, nrow=3, ncol=3)
rv$cachedTbl <<- tbl
return(tbl)
} else{
rv$cachedTbl <<- input$tbl
return(input$tbl)
}
})
output$tblNonEdit <- renderTable({
input$actionButtonID
isolate({
rv$cachedTbl
})
})
}
ui <- shinyUI(pageWithSidebar(
headerPanel("shinyTable with actionButton to apply changes"),
sidebarPanel(
helpText(HTML("
Make changes to the upper table, press the button to activate.
<p>Created using <a href = \"http://github.com/trestletech/shinyTable\">shinyTable</a>."))),
mainPanel(
htable("tbl"),
actionButton("actionButtonID","apply edits"),
tableOutput("tblNonEdit")
)
))
shinyApp(ui = ui, server = server)
【问题讨论】:
标签: r shiny reactive-programming handsontable