-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathflights_demo.qmd
64 lines (49 loc) · 1.29 KB
/
flights_demo.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---
title: "flights_demo"
format: html
server:
type: shiny
---
## Obs + Shiny + Quarto 2
```{ojs}
//| panel: input
//| layout-ncol: 3
var_f = flight_cols
viewof xcol_f = Inputs.select(var_f, {label: "X Variable", value: var_f[0]})
viewof ycol_f = Inputs.select(var_f, {label: "Y Variable", value: var_f[1]})
//viewof bill_length_min = Inputs.range(
// [32, 50],
// {value: 35, step: 1, label: "Bill length (min):"}
//)
```
::: {.panel-fill layout="[ [1] ]"}
```{ojs}
Plot.rect(transpose(selectedData_f), Plot.bin({fillOpacity: "count"}, {x: xcol_f, y: ycol_f})).plot()
```
:::
```{r}
#| context: server-start
library(dplyr)
library(tidyr)
library(nycflights13)
data(flights)
flights <- flights |>
select(all_of(c("year", "dest", "dep_time", "sched_dep_time", "dep_delay", "sched_arr_time", "arr_time", "arr_delay"))) |>
filter(dest %in% c("IAH", "MIA", "BQN", "ATL", "ORD", "FLL", "IAD")) |>
filter(arr_delay < 300)
```
```{r}
#| context: server
flight_cols <- reactive({
#flights |> select(where(is.numeric)) |>
# colnames()
c("dep_time", "sched_dep_time", "dep_delay", "sched_arr_time", "arr_time", "arr_delay")
})
selectedData_f <- reactive({
req(input$xcol_f)
req(input$ycol_f)
col_sel <- c(input$xcol, input$ycol)
flights
})
ojs_define(selectedData_f, flight_cols)
```