gpt4 book ai didi

r - 将数据从 rhandsontable 对象转换为 Shiny 中的数据框

转载 作者:行者123 更新时间:2023-12-04 14:29:20 25 4
gpt4 key购买 nike

我有一个 rHandsontable 表(rhandsontable 包),现在我正在寻找一种将数据从表传输到数据帧的方法。
到目前为止,我还没有找到如何执行此操作的明确线索。
我将非常感谢简单明了的示例或有用的链接。

此外,我还扫描了一个有用的 link .它让我们瞥见了如何在 rhandsontable 对象中操作数据。

但是没有找到关于使用方法的解释。它看起来像一个黑盒测试。如果您能分享一些关于此事的知识(如果有的话),那就太好了。

最佳答案

查看 shinysky package ,因为它使用 Handsontable,它具有 hot.to.df 功能,可让您将数据表转换为 dataframe。下面是一个显示我的意思的最小示例

rm(list = ls())
library(shiny)
library(shinysky)

server <- shinyServer(function(input, output, session) {

# Initiate your table
previous <- reactive({head(mtcars)})

Trigger_orders <- reactive({
if(is.null(input$hotable1)){return(previous())}
else if(!identical(previous(),input$hotable1)){
# hot.to.df function will convert your updated table into the dataframe
as.data.frame(hot.to.df(input$hotable1))
}
})
output$hotable1 <- renderHotable({Trigger_orders()}, readOnly = F)
# You can see the changes you made
output$tbl = DT::renderDataTable(Trigger_orders())
})

ui <- basicPage(mainPanel(column(6,hotable("hotable1")),column(6,DT::dataTableOutput('tbl'))))
shinyApp(ui, server)

关于r - 将数据从 rhandsontable 对象转换为 Shiny 中的数据框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38323985/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com