-
Notifications
You must be signed in to change notification settings - Fork 5
/
76_May_08_2024.qmd
124 lines (84 loc) · 1.54 KB
/
76_May_08_2024.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
---
theme: ../theme.scss
format:
html:
fig-height: 5
fig-dpi: 300
fig-width: 8.88
fig-align: center
knitr:
opts_chunk:
collapse: true
---
```{r}
setwd(here::here('76_May_08_2024'))
library(tidyverse)
theme_set(
theme_minimal(
base_size = 16,
base_family = 'Source Sans Pro'
) +
theme(panel.grid.minor = element_blank())
)
```
```{r}
library(shiny)
ui <- bslib::page_fluid(
sliderInput('slider', 'Slider', min = 1, max = 100, value = 50),
actionButton('button', 'Button'),
textOutput('text')
)
```
```{r}
server <- function(input, output, session) {
output$text <- renderText({
print(input$button)
input$slider
})
}
```
```{r}
#| eval: false
shinyApp(ui, server)
```
```{r}
server <- function(input, output, session) {
output$text <- renderText({
req(input$button >= 1)
print(input$button)
input$slider
})
}
```
```{r}
server <- function(input, output, session) {
output$text <- renderText({
req(input$button >= 1)
print(input$button)
isolate(input$slider)
})
}
```
```{r}
server <- function(input, output, session) {
output$text <- renderText({
req(input$button >= 1)
print(input$button)
input$slider
}) |> bindEvent(input$button)
}
```
```{r}
server <- function(input, output, session) {
observeEvent(
input$button, # Event
{ # Code to execute on event
output$text <- renderText({
req(input$button >= 1)
print(input$button)
input$slider
})
}
)
}
```