【问题标题】:Unable to connec to yahoo URL using Shiny and quantmod无法使用 Shiny 和 quantmod 连接到 yahoo URL
【发布时间】:2016-07-29 10:52:34
【问题描述】:

当我运行以下代码时,我得到了错误:

chartSeries 需要一个 xtsible 对象

请指教。

library(shiny)
library(quantmod)
library(xts)
ui<-fluidPage(
  ##dialogue box for text data 
  textInput(inputId = "text", label = h3("Text input"), value = "Insert stock symbol"),
  plotOutput("hist")      
  )

server<-function(input,output){

stock<-reactive({getSymbols(input$text)})
output$hist<-renderPlot({chartSeries(stock())})

 }

shinyApp(server=server,ui=ui)

【问题讨论】:

    标签: r quantmod shiny


    【解决方案1】:

    这个问题很可能是因为getSymbols 默认没有返回数据。相反,它将数据分配到parent.frame。尝试设置auto.assign = FALSEenv = NULL

    stock <- reactive({getSymbols(input$text, auto.assign = FALSE)})
    # or
    stock <- reactive({getSymbols(input$text, env = NULL)})
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-19
      • 2022-07-17
      • 2019-01-04
      • 2021-08-10
      • 2015-09-20
      • 2019-11-07
      • 1970-01-01
      • 2018-01-21
      相关资源
      最近更新 更多