Пожалуйста, выполните следующий воспроизводимый код, тогда кажется, что событие изменения bins
подсчитывается только один раз, но если мы редактируем таблицу, то событие редактирования таблицы подсчитывается два раза !!
Событие издания таблицы должно учитываться как только одно событие.
Или моя программа неверна?
Пожалуйста, дайте мне знать, как считать событие издания таблицы только одним событием.
DF<-data.frame(h=c( 97L, 32L, 31L),f=c( 1L , 14L, 74L ))
library(shiny)
# Define UI
ui <- fluidPage(
# Application title
titlePanel("Change bins and table"),
rhandsontable::rHandsontableOutput("hot"),# Table of h and f ###########################################################
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a print and history
mainPanel(
h1(" History"),
verbatimTextOutput("history")
)
)
)
# print history of user input
server <- function(input, output) {
values <- shiny::reactiveValues( )
rv <- shiny::reactiveValues()
observeEvent(c(input$bins, input$hot), {
rv$s <-c(rv$s, length( rv$s)+1)
})
output$history <- renderPrint({
# paste(rv$s, collapse = ",")
paste(rv$s, collapse = ",")
})
shiny::observe({
if (!is.null(input$hot)) {
DF = rhandsontable::hot_to_r(input$hot)
} else {
if (is.null(values[["DF"]]))
DF <- DF
else
DF <- values[["DF"]]
}
values[["DF"]] <- DF
})
output$hot <- rhandsontable::renderRHandsontable({
DF <- values[["DF"]]
if (!is.null(DF))
rhandsontable::rhandsontable(DF,
stretchH = "all")
})
}
# Run the application
shinyApp(ui = ui, server = server)