Skip to content

Commit

Permalink
Documentation fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
krystian8207 committed Feb 27, 2023
1 parent 9c699a3 commit f00393c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
14 changes: 11 additions & 3 deletions vignettes/cohortBuilder.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,15 @@ specific source (i.e. `dplyr` for `tblist` and `dbplyr` for `db` source):
code(librarian_cohort)
```

We can see above, the resulting code uses `source` object, which creation can be
We can see above, the resulting code uses `source` object, which creation code can be
defined separately while creating it:

```{r}
librarian_source <- set_source(
as.tblist(librarian),
source_code = quote({
source <- list(attributes = list(datasets = librarian))
source <- list()
source$dtconn <- as.tblist(librarian)
})
)
Expand Down Expand Up @@ -409,7 +410,14 @@ librarian_cohort <- librarian_source %>%
code(librarian_cohort)
```

The second option allows to restore cohort configuration using its state.
What's more, you can manipulate the output with additional arguments:

- `include_methods` - list of methods names which definition should be printed in output,
- `include_action` - list of actions names (such as "pre_filtering") that should be included in output,
- `modifier` - a custom modifier of data.frame storing reproducible code parts,
- `mark_step` - should step ID be presented in output.

The second option for achieving reproducibility allows to restore cohort configuration using its state.
The cohort state is a list (or json) storing information about all the steps and filters configuration.

You may get the state with `get_state` method:
Expand Down
19 changes: 12 additions & 7 deletions vignettes/managing-cohort.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,23 @@ See `vignette("cohort-configuration")`.
The last Cohort configuration component - source, can be also managed within the Cohort itself.
With `update_source` method you can change the source defined in the existing Cohort.

Below we update cohort with Source having `source_code` parameter defined:
Below we update cohort with Source having `source_code` parameter defined.
The argument is responsible to generate `source` object definition printed in the reproducible code (you can use it when the default method doesn't print reasonable output).

```{r}
code(librarian_cohort)
code(librarian_cohort, include_methods = NULL)
new_source <- set_source(
as.tblist(librarian),
source_code = quote({
source <- list(attributes = list(datasets = librarian))
source <- list()
source$dtconn <- as.tblist(librarian)
})
)
update_source(librarian_cohort, new_source)
code(librarian_cohort)
sum_up(librarian_cohort)
code(librarian_cohort)
code(librarian_cohort, include_methods = NULL)
```

Note that updating source doesn't remove Cohort configuration (steps and filters).
Expand All @@ -176,9 +178,12 @@ sum_up(librarian_cohort)
You can also use `update_source` to add Source to an empty Cohort:

```{r}
new_source <- set_source(
as.tblist(librarian)
)
empty_cohort <- cohort()
update_source(librarian_cohort, new_source)
sum_up(empty_cohort)
update_source(empty_cohort, new_source)
code(empty_cohort, include_methods = NULL)
```

The `update_source` method can be also useful if you want to update source along with steps and filters configuration.
Expand Down

0 comments on commit f00393c

Please sign in to comment.