Skip to content

Commit 8c4cb89

Browse files
committed
Clean up example
1 parent 095a7c2 commit 8c4cb89

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

docs/demos/qwebr-read-only.qmd

+16-8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ cat("Your age is: ", age, fill = TRUE)
3636
````
3737
:::
3838

39+
## Constraining Modifications
40+
3941
We can pair `read-only` with `autorun` to create a constrained example allowing us to focus on a single piece of the code.
4042

4143
For example, let's say we want to understand what happens when we increase the number of observations randomly sampled from a normal distribution. We could define two interactive cells:
@@ -51,12 +53,14 @@ Try different values for `n` by modifying the assignment statement.
5153
```{webr-r}
5254
#| context: interactive
5355
#| autorun: true
54-
# Experiment with different sample sizes and, then,
55-
# re-run the next code cell.
56+
# Experiment with different sample sizes by
57+
# changing the n value and re-running the code
58+
# cell.
5659
n <- 100
5760
```
5861

59-
Then, run re-run the graph:
62+
Then, press "Run Code" to recreate the graph and see how the distribution changed:
63+
6064
```{webr-r}
6165
#| context: interactive
6266
#| autorun: true
@@ -74,17 +78,21 @@ hist(samples,
7478
```{webr-r}
7579
#| context: interactive
7680
#| autorun: true
77-
# Experiment with different sample sizes and, then,
78-
# re-run the next code cell.
81+
# Experiment with different sample sizes by
82+
# changing the n value and re-running the code
83+
# cell.
7984
n <- 100
8085
```
8186
```{webr-r}
8287
#| context: interactive
8388
#| autorun: true
8489
#| read-only: true
85-
# Experiment with different sample sizes and, then,
86-
# re-run the next code cell.
87-
n <- 100
90+
samples = rnorm(n)
91+
hist(samples,
92+
main = "Randomly Sampled Normal Distribution",
93+
sub = paste("Based on", n, "samples"),
94+
xlab = "Sample Value"
95+
)
8896
```
8997
````
9098
:::

0 commit comments

Comments
 (0)