Created
November 12, 2020 22:48
-
-
Save jbkunst/4d5bf323e9f24cb5695ed67db0c045df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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