You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: vignettes/qenv.Rmd
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -26,18 +26,17 @@ print(empty_qenv)
26
26
27
27
### `qenv` basic usage
28
28
29
-
The `eval_code()` function executes code within a `qenv` environment, yielding a new `qenv` object as the output.
29
+
The `eval_code()` function executes code within a `qenv` environment, yielding a new `qenv` object as the output.
30
30
31
31
```{r}
32
-
library(magrittr)
33
-
34
32
# evaluate code in qenv
35
33
my_qenv <- eval_code(empty_qenv, "x <- 2")
36
34
print(my_qenv)
37
35
get_env(my_qenv)
38
36
39
37
40
-
q1 <- eval_code(my_qenv, "y <- x * 2") %>% eval_code("z <- y * 2")
38
+
q1 <- eval_code(my_qenv, "y <- x * 2")
39
+
q1 <- eval_code(q1, "z <- y * 2")
41
40
42
41
# my_qenv still contains only x
43
42
print(my_qenv)
@@ -50,7 +49,8 @@ ls(get_env(q1))
50
49
51
50
The same result can be achieved with the `within` method for the `qenv` class.
52
51
```{r}
53
-
q2 <- within(my_qenv, y <- x * 2) %>% within(z <- y * 2)
52
+
q2 <- within(my_qenv, y <- x * 2)
53
+
q2 <- within(q2, z <- y * 2)
54
54
print(q2)
55
55
```
56
56
@@ -66,7 +66,7 @@ cat(get_code(q2))
66
66
```
67
67
68
68
### Substitutions
69
-
In some cases, one may want to substitute some elements of the code before evaluation.
69
+
In some cases, one may want to substitute some elements of the code before evaluation.
70
70
Consider a case when a subset of `iris` is defined by an input value.
71
71
```{r}
72
72
q <- qenv()
@@ -147,11 +147,11 @@ These functions can be seamlessly integrated into `shiny` applications to produc
147
147
148
148
When employing a `qenv` to evaluate code, should an error occur, an object of type `qenv.error` is generated. This object can be utilized wherever a `qenv` object is used, alleviating the need for code alterations to handle these errors. Select the `error_option` in the example below to witness `qenv` error handling in action.
0 commit comments