Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

R Shiny Handsontable automatically updating function after changing a single cell

$
0
0

I am trying to get familiar with the rhandsontable package. So I tried something I thought should be pretty easy but I can't find a solution. Here is the idea:

I am creating a dataframe with random numbers and in a text box. The mean of column 1 of the dataframe should be displayed. Furthermore, that number should be updated as soon as I change the value of a cell in the dataframe.

My code:

ui <- fluidPage(
  textOutput("num"),
  rHandsontableOutput(outputId="frame")
)

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

  datavalue <- reactiveValues(data=df)

  observeEvent(input$frame$changes$changes,{
    mean_col1 <- mean(datavalue$data[[1]][1:10])   
  })        

  output$num <- renderText({
    mean(datavalue$data[[1]][1:10])
  })

  output$frame <- renderRHandsontable({
    rhandsontable(datavalue$data)
  })
}

shinyApp(ui = ui, server = server)

Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>