Skip to content

Commit

Permalink
206 fix failed pipeline (#207)
Browse files Browse the repository at this point in the history
Fixes #206
  • Loading branch information
donyunardi authored Aug 27, 2024
1 parent 6d19f11 commit 700630a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ Suggests:
testthat (>= 3.1.5),
withr (>= 2.0.0)
VignetteBuilder:
knitr
knitr,
rmarkdown
RdMacros:
lifecycle
Config/Needs/verdepcheck: mllg/checkmate, r-lib/lifecycle, r-lib/rlang,
Expand Down
18 changes: 9 additions & 9 deletions vignettes/qenv.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,17 @@ print(empty_qenv)

### `qenv` basic usage

The `eval_code()` function executes code within a `qenv` environment, yielding a new `qenv` object as the output.
The `eval_code()` function executes code within a `qenv` environment, yielding a new `qenv` object as the output.

```{r}
library(magrittr)
# evaluate code in qenv
my_qenv <- eval_code(empty_qenv, "x <- 2")
print(my_qenv)
get_env(my_qenv)
q1 <- eval_code(my_qenv, "y <- x * 2") %>% eval_code("z <- y * 2")
q1 <- eval_code(my_qenv, "y <- x * 2")
q1 <- eval_code(q1, "z <- y * 2")
# my_qenv still contains only x
print(my_qenv)
Expand All @@ -50,7 +49,8 @@ ls(get_env(q1))

The same result can be achieved with the `within` method for the `qenv` class.
```{r}
q2 <- within(my_qenv, y <- x * 2) %>% within(z <- y * 2)
q2 <- within(my_qenv, y <- x * 2)
q2 <- within(q2, z <- y * 2)
print(q2)
```

Expand All @@ -66,7 +66,7 @@ cat(get_code(q2))
```

### Substitutions
In some cases, one may want to substitute some elements of the code before evaluation.
In some cases, one may want to substitute some elements of the code before evaluation.
Consider a case when a subset of `iris` is defined by an input value.
```{r}
q <- qenv()
Expand Down Expand Up @@ -147,11 +147,11 @@ These functions can be seamlessly integrated into `shiny` applications to produc

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.

```{r}
```{r, eval=requireNamespace("shiny")}
library(shiny)
library(magrittr)
# create an initial qenv with the data in
data_q <- qenv() %>% eval_code("iris_data <- iris")
data_q <- qenv()
data_q <- eval_code(data_q, "iris_data <- iris")
ui <- fluidPage(
radioButtons(
Expand Down

0 comments on commit 700630a

Please sign in to comment.