2
votes

I have a rHandsontable table (rhandsontable package) and now I am searching a way how to transfer data from the table into a dataframe.
So far I have not found a clear clue how to perfrom this action.
I would be very grateful for the plain and clear example or useful link.

Besides, I have scanned a useful link. It throws a glimpse of light concerning how to manipulate data inside rhandsontable object.

But no explanation about methods used have been found. It looks like a black box testing. It would be nice if you could share some knowledge of this matter (if any).

2

2 Answers

2
votes

Look into the shinysky package, as it uses Handsontable, which has hot.to.df function that would allow you to convert your datatable into dataframe. Below is a minimal example showing what I mean

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)
1
votes

Well, I have found the way to convert rhandsontable object into dataframe in R.

It seems to be very easy with the function 'hot_to_r' but the overall function description is poor.

So look up some examples and explanations outside the package description (pdf) on CRAN. In my case I have used black-box testing.

Here is my case:

test_case <- hot_to_r(input$all_updates)

The variable 'test_case' is a dataframe.