-
Notifications
You must be signed in to change notification settings - Fork 4
/
Chapter4.Rmd
56 lines (42 loc) · 1.11 KB
/
Chapter4.Rmd
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
---
title: "Chapter4 "
author: "Maya Gans"
date: "3/29/2020"
output: html_document
css: styles.css
---
## 4.3.6.1
Draw the reactive graph for the following server functions:
```{r, eval=FALSE}
server1 <- function(input, output, session) {
c <- reactive(input$a + input$b)
e <- reactive(c() + input$d)
output$f <- renderText(e())
}
```
<img src="www/reactive1.png"></img>
```{r, eval=FALSE}
server2 <- function(input, output, session) {
x <- reactive(input$x1 + input$x2 + input$x3)
y <- reactive(input$y1 + input$y2)
output$z <- renderText(x() / y())
}
```
<img src="www/reactive2.png"></img>
```{r, eval=FALSE}
server3 <- function(input, output, session) {
d <- reactive(c() ^ input$d)
a <- reactive(input$a * 10)
c <- reactive(b() / input$c)
b <- reactive(a() + input$b)
}
```
<img src="www/reactive3.png"></img>
## 4.3.6.2
Can the reactive graph contain a cycle? Why/why not?
No! This will create circular references and a recursion loop!
## 4.4.6.1 TODO
Use reactive expressions to reduce the duplicated code in the following simple apps.
:::note
Unclear what apps this question is referring to
:::