-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_dashboard_R.qmd
164 lines (120 loc) · 2.54 KB
/
delete_dashboard_R.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
---
title: "Palmer Penguins"
format: dashboard
---
```{r}
#| include: false
library(tidyverse)
library(palmerpenguins)
# data(package = 'palmerpenguins')
ojs_define(penguins_OJS = penguins)
```
```{ojs}
// | output: false
penguins = transpose(penguins_OJS)
```
# Page 1
## {.sidebar}
```{ojs}
viewof bill_length_min = Inputs.range(
[32, 50],
{value: 35, step: 1, label: "Bill length (min):"}
)
viewof islands = Inputs.checkbox(
["Torgersen", "Biscoe", "Dream"],
{ value: ["Torgersen", "Biscoe"],
label: "Islands:"
}
)
```
```{ojs}
filtered = penguins.filter(function(penguin) {
return bill_length_min < penguin.bill_length_mm &&
islands.includes(penguin.island);
})
```
## Row
```{r}
#| content: valuebox
#| title: "Penguin Count"
#| color: primary
nrow(penguins)
```
```{r}
#| content: valuebox
#| title: "Penguin Count"
#| color: green
nrow(penguins)
```
::: {.card title="My Title"}
This text will be displayed within a card
:::
## Row
```{ojs}
Plot.rectY(filtered,
Plot.binX(
{y: "count"},
{x: "body_mass_g", fill: "species", thresholds: 20}
))
.plot({
facet: {
data: filtered,
x: "sex",
y: "species",
marginRight: 80
},
marks: [
Plot.frame(),
]
}
)
```
# Page 2
## Row
```{r}
#| content: valuebox
#| title: "Penguin Count"
#| color: primary
nrow(penguins)
```
```{r}
#| content: valuebox
#| title: "Penguin Count"
#| color: green
nrow(penguins)
```
::: {.card title="My Title"}
This text will be displayed within a card
:::
## Row {height=70%}
```{r}
head(penguins)
```
```{r}
#| title: Option 2
knitr::kable(penguins)
```
## Row {height=30%}
### Column {.tabset}
```{ojs}
//| title: Chart 2
Plot.dot(
penguins,
{x: "bill_length_mm", y: "bill_depth_mm", fill: "species"}
).plot()
```
```{r}
#| title: Chart 3
print("1")
```
### Column
```{r}
print("1")
```
::: {.card title="My Title"}
This text will be displayed within a card
:::
# Page 3
I'm thinking that if you use ggplot2 and you want interactivity, the solution is shiny.
If you think shiny is a little silly and would prefer a more professional approach and still be in Quarto, use observable. It has plotting capabilities and interactive user input capabilities. The R/Python to ObservableJS connection is `ojs_define()`. I would not wrangle in observable though.
At the same time, if you're in the R space, use R things!