闪亮的应用程序错误 chartSeries 需要一个 xtsible 对象?

Shiny app Error chartSeries requires an xtsible object?

我有以下闪亮的基本代码:

library(quantmod); library(shiny);

ui <- fluidPage(

  textInput("Symbol","Assign_Symbol","GOOG"),
  dateRangeInput("Date","Assing_Date", start = Sys.Date() - 20, end = Sys.Date()),

  plotOutput("Chart")

)

server <- function(input, output) {
  envSymbol <- new.env()
  Sym <- "Sym"

  envSymbol[[Sym]] <- reactive({
    as.xts(getSymbols(input$Symbol, auto.assign = FALSE))
  })

  output$Chart <- renderPlot({

    chartSeries(
      envSymbol[[Sym]],
      theme = chartTheme("white"),
      type = "line",
      subset = paste(input$Date, collapse = "::")
    )

  })

}

shinyApp(ui, server)

window 按预期出现符号和日期,但在图表部分我总是得到 Error: chartSeries requires an xtsible object

我不知道 shiny,这是来自在线代码示例。我发现了更长更复杂的样本,但我仍然遇到相同的 xtsible 对象错误。

有人能告诉我我错过了什么吗?

反应式表达式 envSymbol[[Sym]] 在技术上是一个函数。所以要调用它,你必须在调用 chartSeries 时用括号 ( envSymbol[[Sym]]() ) 调用它。有关更多详细信息,请查看 this video。 (应该在 1h03m 左右开始)