r - How to read edited rhandsontable in another tableoutput in shiny? -


i trying make simple calculator in shiny, first create rhandsontable input given , read values in rhandsontable create table output gives final calculation. running following code this, final calculations not being updated when edit rhandsontable.

ui.r

library(shiny) library(rhandsontable)  fluidpage(    titlepanel("test app"),   sidebarlayout(     sidebarpanel(        numericinput("loc", "unique location id", na),        submitbutton("submit"),        width = 2     ),      mainpanel(        tabsetpanel(         tabpanel("                   h4("edit details:"),                   rhandsontableoutput('edit'),                   h4("final details:"),                   tableoutput('fin')         )       )     )   ) ) 

server.r

library(shiny)  shinyserver(function(input, output) {    final<- reactive({      ##here dataset based on location id input     ##the dataset has columns(in order): location_id, name, age, salary, household_size, avg_amount_per_person     ##avg_amount_per_person = salary/household_size     ##it has totals row, show complete dataset in separate tab   })    ##now creating rhandsontable shown in 'custom' tab    values<- reactivevalues()    data<-  reactive({     if (!is.null(input$hot)) {       df<-  hot_to_r(input$hot)     } else {       if (is.null(values[["df"]]))         df<-  final()[1:(nrow(final())-1),c(1,2,4)] #this exclude totals row , select location_id, name, salary columns final()       else         df<- values[["df"]]     }      values[["df"]]<-df      df   })    output$edit <- renderrhandsontable({     df<-  data()     if (!is.null(df))       rhandsontable(df, usetypes = true)   })    final2<- reactive({      fnf<- final()[1:(nrow(final())-1),]      fnf$salary<- data()$salary      fnf$avg_amount_per_person<- data()$salary/fnf$household_size       ##here create totals row in fnf      fnf   })    output$fin<- rendertable(final2())  }) 

can please me going wrong? in advance :)


Comments

Popular posts from this blog

c++ - CPP, 'X' button listener -

shared memory - gstreamer shmsrc and shmsink with h264 data -

.net - Bulk insert via Dapper is slower than inserting rows one-by-one -