I have two problems: -First I cannot start the table showing only zeros or blank for that reason I've created a button that set's every thing to zero which kind of works but its not ideal. -Secondly, I'm trying to calculate column sum for each column in a rhandontable but so far I havent been able to make it work.
I have been looking around for similar problems and I have found some code that looked promissing but in the end it only provided the sum for a single column or with some changes it would sum up all columns which is not what I'm after.
ui <- fluidPage(
rHandsontableOutput('table'),
textOutput('result'),
actionButton("recalc", "re-enter data")
)
season<-c("Spring","Summer","Autum","Winter")
server <- function(input,output,session)({
values <- reactiveValues(data = NULL) ## assign it with NULL
## button press resets now the data frame
observeEvent(input$recalc, {
values$data[] <- 0
})
## changes in numericInput sets all (!) new values
observe({
values$data <-data.frame(row.names=season,Lake=1:4,Beach=1:4, Garden=1:4,stringsAsFactors = FALSE)
})
observe({
if(!is.null(input$table))
values$data <- hot_to_r(input$table)
})
output$table <- renderRHandsontable({
req(values$data)
rhandsontable(values$data,rowHeaderWidth = 100)
})
})
shinyApp(ui = ui, server = server)
The expected results would be a 5th column with the sum of each column. A starting table filled with zeros or blank.
If anyone could point me in the right direction it would be very much appreciated.