Skip to content

Commit b1d356a

Browse files
return to slow app
1 parent 3d4d5f0 commit b1d356a

File tree

1 file changed

+22
-37
lines changed

1 file changed

+22
-37
lines changed

app.R

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
library(shiny)
22
library(bslib)
33
library(tidyverse)
4-
library(future)
5-
library(promises)
64

7-
plan(multisession)
8-
9-
survey <- arrow::read_parquet("data/survey.parquet")
5+
survey <- read.csv("data/survey.csv") |>
6+
slice_sample(n = 5000, by = region)
107

118
ui <- page_sidebar(
129

@@ -23,77 +20,65 @@ ui <- page_sidebar(
2320
max = 100,
2421
value = 100,
2522
step = 10
26-
),
27-
input_task_button(
28-
id = "compute",
29-
label = "Calcular"
3023
)
3124
),
3225

3326
useBusyIndicators(),
3427

3528
card(
3629
max_height = "50%",
37-
DT::DTOutput("table")
30+
tableOutput("table")
3831
),
3932

4033
layout_columns(
4134
col_widths = c(4, 4, 4),
4235

4336
card(
44-
plotly::plotlyOutput("histogram")
37+
plotOutput("histogram")
4538
),
4639
card(
4740
full_screen = TRUE,
48-
plotly::plotlyOutput("by_transport")
41+
plotOutput("by_transport")
4942
),
5043
card(
5144
full_screen = TRUE,
52-
plotly::plotlyOutput("by_type")
45+
plotOutput("by_type")
5346
)
5447

5548
)
5649

5750
)
5851

5952
server <- function(input, output, session) {
60-
filter_task <- ExtendedTask$new(function(p_survey, p_region, p_age) {
61-
future_promise({
62-
p_survey |>
63-
dplyr::filter(region == p_region) |>
64-
dplyr::filter(age <= p_age)
65-
})
66-
}) |>
67-
bind_task_button("compute")
68-
69-
observe(filter_task$invoke(survey, input$region, input$age)) |>
70-
bindEvent(input$compute, ignoreNULL = FALSE)
71-
72-
filtered <- reactive({
73-
filter_task$result()
74-
})
75-
76-
output$table <- DT::renderDT({
77-
filtered()
53+
output$table <- renderTable({
54+
survey |>
55+
filter(region == input$region) |>
56+
filter(age <= input$age)
7857
})
7958

80-
output$histogram <- plotly::renderPlotly({
81-
filtered() |>
59+
output$histogram <- renderPlot({
60+
survey |>
61+
filter(region == input$region) |>
62+
filter(age <= input$age) |>
8263
ggplot(aes(temps_trajet_en_heures)) +
8364
geom_histogram(bins = 20) +
8465
theme_light()
8566
})
8667

87-
output$by_transport <- plotly::renderPlotly({
88-
filtered() |>
68+
output$by_transport <- renderPlot({
69+
survey |>
70+
filter(region == input$region) |>
71+
filter(age <= input$age) |>
8972
ggplot(aes(temps_trajet_en_heures)) +
9073
geom_histogram(bins = 20) +
9174
facet_wrap(~transport) +
9275
theme_light()
9376
})
9477

95-
output$by_type <- plotly::renderPlotly({
96-
filtered() |>
78+
output$by_type <- renderPlot({
79+
survey |>
80+
filter(region == input$region) |>
81+
filter(age <= input$age) |>
9782
ggplot(aes(temps_trajet_en_heures)) +
9883
geom_histogram(bins = 20) +
9984
facet_wrap(~type) +

0 commit comments

Comments
 (0)