Skip to content

Instantly share code, notes, and snippets.

@jbkunst
Created November 12, 2020 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbkunst/4d5bf323e9f24cb5695ed67db0c045df to your computer and use it in GitHub Desktop.
Save jbkunst/4d5bf323e9f24cb5695ed67db0c045df to your computer and use it in GitHub Desktop.
library(shiny)
library(forecast)
library(xts)
library(tradestatistics)
library(ggplot2)
# este es un input ficticio (posible) con el cual yo haré pruebas de mi código
# input <- list(pais = "chn")
ui <- fluidPage(
titlePanel("Super ultra app de predicción de exportaciones"),
sidebarLayout(
sidebarPanel(
selectInput("pais", label = "Seleccione el país a analizar:", choices = c("chl", "chn", "mex"))
),
mainPanel(
plotOutput("predplot")
)
)
)
server <- function(input, output) {
output$predplot <- renderPlot({
# codigo que genera el grafico, tomando como input el pais
# que seleccionó el usuario
pais <- input$pais
# pais <- "arg"
data <- ots_create_tidy_data(years = 1990:2018, reporters = pais, table = "yr")
valores <- data$export_value_usd
fechas <- as.Date(paste0(data$year, "0101"), format = "%Y%m%d")
serie <- xts(valores, order.by = fechas)
prediccion <- forecast(serie, h = 5)
autoplot(prediccion)
})
}
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment