【发布时间】:2019-09-22 09:44:00
【问题描述】:
我什至不确定我想要的输出是否可能,但我想问一下,以防万一,因为我非常卡在这个问题上。我正在构建一个闪亮的应用程序,其中有一个 rHandsontableOutput 对象。当我更新表的第 4 列时,我希望它自动将表的 5-16 列乘以第 4 列中的新值。我很难让我的 multiplied 结果显示在我的表格中。 rHandsontable 对我来说有点难以掌握。我知道如何在表格中显示数据,然后在 another 输出对象中使用它,但我对如何在同一个输出对象中使用它有点困惑。它宁愿不必求助于文本输入来更新表格或某种其他类型的非表格格式的解决方案。任何帮助或替代解决方案将不胜感激!
我参考了其他一些帖子,但都没有成功。
show the sum of specific columns based on rhandsontable values
Update handsontable by editing table and/or eventReactive
Flexdashboard, rhandsontable: how to programmatically access user updated table?
我的代码如下:
#ui
... fluidRow(
column(width=8,
box(
width = NULL, div(rHandsontableOutput('contents'), style = "font-size: 92%"),title = "Potential View",
status = "primary", solidHeader = TRUE)
# img(height = "500px", alt="SNAP Logo", src="overlay.png"))
)
)...
#server
indat <- reactiveValues(data=table_1)
observe({
if(!is.null(input$contents))
indat$data <- hot_to_r(input$contents)
})
output$contents <- renderRHandsontable({
tbl <- rhandsontable(indat$data) %>% hot_col(col = c(1,2,3), readOnly = TRUE)
c=as.vector(tbl$col_4)
tbl_new = tbl[,c(5:16)]
test= data.frame(mapply(`*`,tbl_new,c))
return(test)
})
我也尝试过点击按钮更新表格,或者只创建一个可编辑的矢量并将其与新表格绑定,但我对这两种解决方案都没有运气。
【问题讨论】:
标签: r shiny shiny-reactivity rhandsontable shinyapps