0
我發現有關更新數據輸出的問題。 腳本是follwos:rHandsontable對象(hot_to_r)中已更新輸出的錯誤呈現
library(shiny)
library(shinyapps)
library(rhandsontable)
## CLIENT SIDE
ui <- shinyUI(pageWithSidebar(
headerPanel("Test of rHandsontable output - hot_to_r function"),
sidebarPanel(
actionButton("goButton", "test rhandsontable")
),
mainPanel(
rHandsontableOutput("all_updates")
,verbatimTextOutput('df_output')
)
))
## SERVER SIDE
server <- shinyServer(function(input, output) {
observeEvent(input$goButton,{
df <- data.frame (x=1:10
,y=1:10
,z=factor(c("X","P"))
,merge_xy="merger"
)
df[,4] <- paste(df[,1],"+",df[,2])
output$all_updates <- renderRHandsontable({
rhandsontable(df, selectCallback = TRUE, height = 300) %>%
hot_table(highlightCol = TRUE, highlightRow = TRUE) %>%
hot_rows(rowHeights = 18)
})
})
observeEvent(input$all_updates,{
zzz <- hot_to_r(input$all_updates)
zzz[,4] <- paste(zzz[,1],'+',zzz[,2],'+',zzz[,3])
#the output of the modified dataframe
print(zzz)
output$all_updates <-renderRHandsontable({
rhandsontable(zzz, selectCallback = TRUE, height = 300) %>%
hot_table(highlightCol = TRUE, highlightRow = TRUE) %>%
hot_rows(rowHeights = 18)
})
print(hot_to_r(input$all_updates))
output$df_output <- renderPrint(
print(hot_to_r(input$all_updates))
)
})
output$all_updates <- renderRHandsontable({
df <- data.frame (x=integer(10)
,y=integer(10)
,z=factor(c("X","P"))
,merge_xy="merger"
)
rhandsontable(df, selectCallback = TRUE, height = 300) %>%
hot_table(highlightCol = TRUE, highlightRow = TRUE) %>%
hot_rows(rowHeights = 18)
})
})
shinyApp(ui=ui,server=server)
的問題是,從rHandsontable功能 'hot_to_r' 迴歸數據集的一步延遲。
您可以更改列以Z實驗:
表的輸出已立即更新列中的任何改變,但「hot_to_r」函數的輸出後產生的以前版本的快照表(沒有最新的變化)。