Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
calderonsamuel committed Nov 14, 2024
0 parents commit 4790861
Show file tree
Hide file tree
Showing 8 changed files with 900,312 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.Rproj.user
.Renviron
87 changes: 87 additions & 0 deletions app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
library(shiny)
library(bslib)
library(tidyverse)

survey <- readr::read_csv("data/survey.csv") |>
slice_sample(n = 5000, by = region)

ui <- page_sidebar(

sidebar = sidebar(
selectInput(
inputId = "region",
label = "Seleccione region",
choices = discard(unique(survey$region), is.na)
),
sliderInput(
inputId = "age",
label = "Seleccione edad máxima",
min = 10,
max = 100,
value = 100,
step = 10
)
),

card(
max_height = "50%",
tableOutput("table")
),

layout_columns(
col_widths = c(4, 4, 4),

card(
plotOutput("histogram")
),
card(
full_screen = TRUE,
plotOutput("by_transport")
),
card(
full_screen = TRUE,
plotOutput("by_type")
)

)

)

server <- function(input, output, session) {
output$table <- renderTable({
survey |>
filter(region == input$region) |>
filter(age <= input$age)
})

output$histogram <- renderPlot({
survey |>
filter(region == input$region) |>
filter(age <= input$age) |>
ggplot(aes(temps_trajet_en_heures)) +
geom_histogram(bins = 20) +
theme_light()
})

output$by_transport <- renderPlot({
survey |>
filter(region == input$region) |>
filter(age <= input$age) |>
ggplot(aes(temps_trajet_en_heures)) +
geom_histogram(bins = 20) +
facet_wrap(~transport) +
theme_light()
})

output$by_type <- renderPlot({
survey |>
filter(region == input$region) |>
filter(age <= input$age) |>
ggplot(aes(temps_trajet_en_heures)) +
geom_histogram(bins = 20) +
facet_wrap(~type) +
theme_light()
})
}

shinyApp(ui, server)
Loading

0 comments on commit 4790861

Please sign in to comment.