我的ui.r
library(shiny)
codes <- paste("CURRENCY:",currencies,sep="")
currencies <- c("ARS","AUD","BRL","CAD","CHF",
"CNY","DKK","EUR","GBP","IDR",
"ILS","INR", "JPY","MXN","MYR",
"NOK","NZD","PHP","RUB","SEK",
"THB","TRY")
shinyUI(fluidPage(
titlePanel("Currency Charts"),
sidebarLayout(
sidebarPanel(
helpText("Select a currency to examine.
Information will be collected from Quandl."),
selectInput("symb",
label = "Choose a variable to display",
choices = currencies,
selected = "ARS"),
dateRangeInput("dates",
"Date range",
start = "2013-01-01",
end = as.character(Sys.Date())),
actionButton("get", "Get Currency"),
br(),
br(),
)
mainPanel(plotOutput("plot"))
)
))
server.r
library(quantmod)
shinyServer(function(input, output) {
output$plot <- renderPlot({
data <- getSymbols(input$symb, src = "google",
from = input$dates[1],
to = input$dates[2],
auto.assign = FALSE)
chartSeries(data, theme = chartTheme("white"),
type = "line", TA = NULL)
})
})
问题:我在第35行遇到意外的符号错误。
我基本上复制了Shiny R给出的示例代码,但我试图使用他们来自雅虎的股票信息图,改为使用google来绘制货币。 CURRENCY:XYZ在谷歌财务中给出了XYZ / USD,这就是ui.r的第一部分。我认为问题在于我使用了getSymbol()和renderPlot()。有什么建议/修正吗?
答案 0 :(得分:1)
你似乎有2个逗号放错了地方
所以这个修改过的函数应该这样做:
library(shiny)
currencies <- c("ARS","AUD","BRL","CAD","CHF",
"CNY","DKK","EUR","GBP","IDR",
"ILS","INR", "JPY","MXN","MYR",
"NOK","NZD","PHP","RUB","SEK",
"THB","TRY")
codes <- paste("CURRENCY:",currencies,sep="")
shinyUI(fluidPage(
titlePanel("Currency Charts"),
sidebarLayout(
sidebarPanel(
helpText("Select a currency to examine.
Information will be collected from Quandl."),
selectInput("symb",
label = "Choose a variable to display",
choices = currencies,
selected = "ARS"),
dateRangeInput("dates",
"Date range",
start = "2013-01-01",
end = as.character(Sys.Date())),
actionButton("get", "Get Currency"),
br(),
br()
),
mainPanel(plotOutput("plot"))
)
))