我希望你很好。我试图创建一个闪亮的仪表板,用户可以从另一个更新一个rhandsontable。我的代码如下:r shiny:更新rhandsontable从另一个rhandsontable
library(shiny)
library(rhandsontable)
channel <- c("TV","Radio","Digital")
start.date <- as.Date("2017-01-01")
end.date <- as.Date("2017-01-07")
date.range <- as.POSIXct((seq(start.date,end.date,by="day")), origin = "1970-01-01")
date.range <- as.data.frame(date.range)
colnames(date.range) <- c("date")
date.range[channel] <- 0
table1 <- date.range
table2 <- date.range
#Define the tables.
ui <- fluidPage(
br(),
fluidRow(
column(4, rHandsontableOutput("table1output")),
column(4, rHandsontableOutput("table2output"))
))
server <- function(input,output,session){
table <- reactiveValues()
table$table1 <- table1
table$table2 <- table2
#define reactive values as table1 and table2
output$table1output <- renderRHandsontable({rhandsontable(table$table1)})
output$table2output <- renderRHandsontable({rhandsontable(table$table2)})
#rhandsontable outputs
observeEvent(input$table1output,{
df <- hot_to_r(input$table1output)
df <- as.data.frame(df)
table$table2 <- df
})
#if a user updates table1 table2 should also update.
observeEvent(input$table2output,{
df <- hot_to_r(input$table2output)
df <- as.data.frame(df)
table$table1 <- df
})
#if a user updates table2 table1 should also update.
}
shinyApp(ui = ui, server = server)
每当我运行代码我得到以下错误:
Warning: Error in as: no method or default for coercing “character” to “NA”
我不能为我的生命得到这个工作!任何帮助将非常感谢!
干杯,
哈利
看起来像日期是问题。如果我用其他替换桌子,一切工作正常。看看如何在'rhandsontable'中使用日期列。根据[源文件](https://jrowen.github.io/rhandsontable/),'Sys.Date()'中的'Date'是一个允许的格式。 –