'rhandsontable: need to view table before using in calculations?
I have a Shiny app where the user uploads a bunch of input tables via CSV. These tables are then make into rhandsontables which are used in subsequent calculations. I am using rhandsontable to allow the user to modify the tables as necessary.
As it stands, my code looks roughly like this:
UI:
rHandsontableOutput("mytable_out")
server:
mytable <- reactive({*code to upload from CSV* })
output$mytable_out <- renderRHandsontable(rhandsontable(mytable()) )
#Within an actionbutton observeEvent:
mytable_useforcalcs <- hot_to_r(input$mytable_out )
#use mytable_useforcalcs in the subsequent calculations
This works well except for one issue. In order to use mytable_useforcalcs in the subsequent calculations, I first have to actually click onto the tab that contains my RHOT output$mytable_out. In the actual app, this can take a while as there are a bunch of tables, many of them quite large. I'd like to be able to just upload my CSV files and click the actionButton that starts the calculations. Unfortunately, if I do that I get errors because my code cannot find input$mytable_out and thus cannot make mytable_useforcalcs.
Solution 1:[1]
This works, put it in the actionbutton ObserveEvent:
mytable_useforcalcs <- if(!is.null(input$mytable_out)){hot_to_r(input$mytable_out)} else { isolate( mytable()) }
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ralph Asher |
