[英]Shiny App - Having trouble plotting a stock line chart
I am trying to map a stock line chart using quantmod in the shiny app.我正在尝试 map 在 shiny 应用程序中使用 quantmod 的股票折线图。 Getting an error.
收到错误。 Warning: Error in sourceUTF8: Error sourcing /home/ccc_v1_w_62aa8_36923/asn122362_7/asn122367_1/Dashboard 4Dec/9 Dec Stock APP TESTING/Testing Stock App/server.R [No stack trace available] Error in sourceUTF8(serverR, envir = new.env(parent = sharedEnv)):
警告:sourceUTF8 中的错误:错误采购 /home/ccc_v1_w_62aa8_36923/asn122362_7/asn122367_1/Dashboard 4Dec/9 Dec Stock APP TESTING/Testing Stock App/server.R [No stack trace available = new] sourceUTF8 中的错误(server.envR, envir (父 = sharedEnv)):
Server.R
library(quantmod)
shinyServer(function(input, output){
price <- getSymbols(input$stockInput,
type="line",
from='2019',
theme=chartTheme('white'),
auto.assign = F)
plot(price, main = input$stockInput)})
ui.R
library(shiny)
shinyUI(fluidPage(
titlePanel("Stock Chart"),
sidebarLayout(
sidebarPanel(
#This is a dropdown to select the stock
selectInput("stockInput",
"Pick your stock:",
c("AMZN","FB","GOOG","NVDA","AAPL"),
"AMZN"),selected = "GOOG"),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
))))
Try this尝试这个
library(quantmod)
server <- shinyServer(function(input, output){
observe({
price <- getSymbols(req(input$stockInput),
type="line",
from="2015-01-01",to="2016-01-01",
theme=chartTheme('white'),
auto.assign = F)
output$distPlot <- renderPlot({
plot(price, main = req(input$stockInput))
})
})
})
### ui.R
library(shiny)
ui <- shinyUI(fluidPage(
titlePanel("Stock Chart"),
sidebarLayout(
sidebarPanel(
#This is a dropdown to select the stock
selectInput("stockInput",
"Pick your stock:",
choices = c("AMZN","FB","GOOG","NVDA","AAPL"),
selected = "GOOG")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)))
shiny::shinyApp(ui, server)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.