闪亮的应用程序错误图表系列需要一个 xtsible 对象? [英] Shiny app Error chartSeries requires an xtsible object?

查看:110
本文介绍了闪亮的应用程序错误图表系列需要一个 xtsible 对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have following basic code with shiny:

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)

窗口按预期显示符号和日期,但在图表部分我总是得到错误:chartSeries需要一个xtsible对象

The window comes up with symbol and date as expected, but in the chart section I always get Error: chartSeries requires an xtsible object

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

I don't know shiny and this is from code samples online. I have found longer more complicated samples, but I still get the same xtsible object error.

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

Can somebody tell me what I am missing?

推荐答案

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

The reactive expression envSymbol[[Sym]] is technically a function. So to call it you must call it with parenthesis ( envSymbol[[Sym]]() ) when calling chartSeries. For more detailed information have a look at this video. (should start at around 1h03m)

这篇关于闪亮的应用程序错误图表系列需要一个 xtsible 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆