【发布时间】:2021-02-02 07:55:22
【问题描述】:
我不明白为什么这个应用程序不起作用? 该应用程序在没有服务器部分内容的情况下工作。 它适用于 UI 定义和服务器功能为空。 当我在服务器函数中添加 ggplot 代码时,应用程序叶子就可以工作了。 你能帮帮我吗?
谢谢
#install.packages("quantmod")
#install.packages('circlepackeR')
library(quantmod)
library(ggplot2)
library(shiny)
library(data.table)
library(plotly)
library(shinydashboard)
apple=as.data.frame(getSymbols("AAPL", src = "yahoo", from = "2010-01-01", to = "2020-10-15", auto.assign = FALSE))
colnames(apple)=c('Apertura','Maximo','Minimo','Cierre','Volumen','Ajustado')
apple$fecha=as.Date(rownames(apple))
ui <- fluidPage(
dashboardPage(
dashboardHeader(title = "SP500 Top-5"),
dashboardSidebar(
sidebarMenu(
menuItem("Apple", tabName = "aapl")
)
),
dashboardBody(
# tags$head(
# tags$link(rel = "stylesheet", type = "text/css", href = "custom.css")
# ),
tabItems(
tabItem(tabName = "aapl",
fluidRow(
tabsetPanel(
tabPanel("Plot", plotOutput("plota1")),
tabPanel("Summary", verbatimTextOutput("summary")),
tabPanel("Table", tableOutput("table"))
)))))))
server <- function(input, output) {
apple=reactive({apple})
output$plota1 <- renderPlot({
g=ggplot()+
geom_line(mapping=aes(x=fecha, y=Cierre), data=apple(), size=1, alpha=0.5)+
scale_x_date("Fecha") + scale_y_continuous(name="Serie de precios de cierre")+
ggtitle ("Comportamiento diario de la acción APPPLE")
g
})
}
shinyApp(ui = ui, server = server)
【问题讨论】:
标签: r shiny shiny-server