闪亮的预测图
Shiny Forecast Plot
我在编写一个应用程序时遇到问题,该应用程序是带有预测库的绘图但未显示。
-我想要这个带有滑块范围输入的图,以便您可以设置置信率。表示在"level".
-不要太在意复选框。
这里是代码:
library(shiny)
ui <- fluidPage(
(titlePanel("app | Forecast Models", windowTitle =
"app")),
#Range Input
sliderInput(inputId = "range",
label = "Set Confidence Interval",
min = 0,max = 100, value = c(60,90),
step = NULL,
plotOutput(outputId = "percent")),
#Checkbox input
checkboxGroupInput(inputId = "checkbox", label = "Select Forecast",
choices = c("Trend","Level"),
plotOutput(outputId = "hist"), inline = T))
#server.R
library(forecast)
timese <- ts(WWWusage, start= c(2008,1), end= c(2016,1), frequency=12)
fit <- StructTS(timese,"trend")
server <- function(input, output) {
output$percent <- 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 = ui, server = server)
你的 ui
应该是这样的(你忘记了 plotOutput("percent")
部分,所以 R
不知道它应该画什么):
ui <- fluidPage(
titlePanel("app | Forecast Models", windowTitle = "app"),
sliderInput(inputId = "range",
label = "Set Confidence Interval",
min = 0,max = 100, value = c(60,90),
step = NULL),
checkboxGroupInput(inputId = "checkbox", label = "Select Forecast",
choices = c("Trend","Level"),
plotOutput(outputId = "hist"), inline = T),
plotOutput("percent")
)
你没有mainPanel
rm(list = ls())
library(shiny)
library(forecast)
timese <- ts(WWWusage, start= c(2008,1), end= c(2016,1), frequency=12)
fit <- StructTS(timese,"trend")
ui <- fluidPage(
(titlePanel("app | Forecast Models", windowTitle = "app")),
#Range Input
sliderInput(inputId = "range",
label = "Set Confidence Interval",
min = 0,max = 100, value = c(60,90)),
#Checkbox input
checkboxGroupInput(inputId = "checkbox", label = "Select Forecast",choices = c("Trend","Level"),plotOutput(outputId = "hist"), inline = T),
mainPanel(plotOutput(outputId = "percent"))
)
server <- function(input, output) {
output$percent <- 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)
我在编写一个应用程序时遇到问题,该应用程序是带有预测库的绘图但未显示。
-我想要这个带有滑块范围输入的图,以便您可以设置置信率。表示在"level".
-不要太在意复选框。
这里是代码:
library(shiny)
ui <- fluidPage(
(titlePanel("app | Forecast Models", windowTitle =
"app")),
#Range Input
sliderInput(inputId = "range",
label = "Set Confidence Interval",
min = 0,max = 100, value = c(60,90),
step = NULL,
plotOutput(outputId = "percent")),
#Checkbox input
checkboxGroupInput(inputId = "checkbox", label = "Select Forecast",
choices = c("Trend","Level"),
plotOutput(outputId = "hist"), inline = T))
#server.R
library(forecast)
timese <- ts(WWWusage, start= c(2008,1), end= c(2016,1), frequency=12)
fit <- StructTS(timese,"trend")
server <- function(input, output) {
output$percent <- 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 = ui, server = server)
你的 ui
应该是这样的(你忘记了 plotOutput("percent")
部分,所以 R
不知道它应该画什么):
ui <- fluidPage(
titlePanel("app | Forecast Models", windowTitle = "app"),
sliderInput(inputId = "range",
label = "Set Confidence Interval",
min = 0,max = 100, value = c(60,90),
step = NULL),
checkboxGroupInput(inputId = "checkbox", label = "Select Forecast",
choices = c("Trend","Level"),
plotOutput(outputId = "hist"), inline = T),
plotOutput("percent")
)
你没有mainPanel
rm(list = ls())
library(shiny)
library(forecast)
timese <- ts(WWWusage, start= c(2008,1), end= c(2016,1), frequency=12)
fit <- StructTS(timese,"trend")
ui <- fluidPage(
(titlePanel("app | Forecast Models", windowTitle = "app")),
#Range Input
sliderInput(inputId = "range",
label = "Set Confidence Interval",
min = 0,max = 100, value = c(60,90)),
#Checkbox input
checkboxGroupInput(inputId = "checkbox", label = "Select Forecast",choices = c("Trend","Level"),plotOutput(outputId = "hist"), inline = T),
mainPanel(plotOutput(outputId = "percent"))
)
server <- function(input, output) {
output$percent <- 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)