jorandradefig

shiny.R

Jun 13th, 2021
707
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pacman::p_load(
  2.   tidyverse,
  3.   plotly,
  4.   shiny
  5. )
  6.  
  7. ui <- fluidPage(
  8.   sidebarLayout(
  9.     inputPanel(
  10.       selectInput(
  11.         inputId="type",
  12.         label="Tipo:",
  13.         choices=unique(trend_data$type),
  14.         selected="advert"
  15.       )
  16.     ),
  17.     mainPanel(
  18.       plotOutput(
  19.         outputId="plot"
  20.       ),
  21.       tableOutput(
  22.         outputId="table"
  23.       )
  24.     )
  25.   )
  26. )
  27.  
  28. server <- function(input,output) {
  29.   trend_data <- read_csv("jorandradefig/193/input/google-trends/trend_data.csv")
  30.   output$table <- renderTable({
  31.     trend_data %>%
  32.       filter(type == input$type)
  33.   })
  34.  
  35.   output$plot <- renderPlot({
  36.     data <- trend_data %>%
  37.       filter(type == input$type)
  38.     ggplot(data,aes(x=date,y=close)) +
  39.       geom_line()
  40.   })
  41. }
  42.  
  43. shinyApp(ui,server)
RAW Paste Data