【发布时间】:2016-02-13 13:37:43
【问题描述】:
我有这段代码,我希望有一个选择输入选项来从两种不同的图形绘制方式中进行选择。
如果您选择“级别”选项,我希望“适合 2”被绘制而不是仅仅适合。
这很合适。
plot(forecast(fit2,
#Confidence Interval %
level = c(70,90)),
sub= "Confidence Interval 70% ~ 90%
or Determined by user",
ylab= "Y Axis Variable",
main= "Forecast Linear Structural Model @ Level-Wise",
ylim = c(0,400))
这是闪亮的代码。
library(forecast)
library(shiny)
timese <- ts(WWWusage, start= c(2008,1), end= c(2016,1), frequency=12)
fit <- StructTS(timese,"trend")
fit2 <- StructTS(timese,"level")
ui <- fluidPage(
(titlePanel("app | Forecast Models", windowTitle = "app")),
#Select input
selectInput(inputId = "select", label = "Select Forecast",
choices = c("Trend","Level"),
plotOutput(outputId = "hist")),
#Range Input
sliderInput(inputId = "range",
label = "Set Confidence Interval. Up to 99%",
min = 0,max = 99, value = c(60,90)),
mainPanel(plotOutput(outputId = "plot"))
)
server <- function(input, output) {
output$plot <- renderPlot({
plot(forecast(fit, #Confidence Interval %
level = c(input$range)),
sub= "Confidence Interval 70% ~ 90% or Determined by user",
ylab= "Y Axis Variable",
main= "Forecast Linear Structural Model @ Trend-Wise",
ylim = c(0,400))
})
}
shinyApp(ui, server)
【问题讨论】:
标签: r plot shiny forecasting