From b1d356a4f0ad2e7f94f311ed6685727c70334263 Mon Sep 17 00:00:00 2001 From: Samuel Calderon Date: Mon, 18 Nov 2024 02:16:19 -0500 Subject: [PATCH] return to slow app --- app.R | 59 ++++++++++++++++++++++------------------------------------- 1 file changed, 22 insertions(+), 37 deletions(-) diff --git a/app.R b/app.R index bb304b2..2febec7 100644 --- a/app.R +++ b/app.R @@ -1,12 +1,9 @@ library(shiny) library(bslib) library(tidyverse) -library(future) -library(promises) -plan(multisession) - -survey <- arrow::read_parquet("data/survey.parquet") +survey <- read.csv("data/survey.csv") |> + slice_sample(n = 5000, by = region) ui <- page_sidebar( @@ -23,10 +20,6 @@ ui <- page_sidebar( max = 100, value = 100, step = 10 - ), - input_task_button( - id = "compute", - label = "Calcular" ) ), @@ -34,22 +27,22 @@ ui <- page_sidebar( card( max_height = "50%", - DT::DTOutput("table") + tableOutput("table") ), layout_columns( col_widths = c(4, 4, 4), card( - plotly::plotlyOutput("histogram") + plotOutput("histogram") ), card( full_screen = TRUE, - plotly::plotlyOutput("by_transport") + plotOutput("by_transport") ), card( full_screen = TRUE, - plotly::plotlyOutput("by_type") + plotOutput("by_type") ) ) @@ -57,43 +50,35 @@ ui <- page_sidebar( ) server <- function(input, output, session) { - filter_task <- ExtendedTask$new(function(p_survey, p_region, p_age) { - future_promise({ - p_survey |> - dplyr::filter(region == p_region) |> - dplyr::filter(age <= p_age) - }) - }) |> - bind_task_button("compute") - - observe(filter_task$invoke(survey, input$region, input$age)) |> - bindEvent(input$compute, ignoreNULL = FALSE) - - filtered <- reactive({ - filter_task$result() - }) - - output$table <- DT::renderDT({ - filtered() + output$table <- renderTable({ + survey |> + filter(region == input$region) |> + filter(age <= input$age) }) - output$histogram <- plotly::renderPlotly({ - filtered() |> + 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 <- plotly::renderPlotly({ - filtered() |> + 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 <- plotly::renderPlotly({ - filtered() |> + 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) +