R6 class representing Cohort object.
R6 class representing Cohort object.
Methods
Method new()
Create Cohort object.
Arguments
source
Source object created with set_source.
...
Steps definition (optional). Can be also defined as a sequence of filters - the filters will be added to the first step.
run_flow
If `TRUE`, data flow is run after the operation is completed.
hook
List of hooks describing methods before/after the Cohort is created. See hooks for more details.
Method add_source()
Add Source to Cohort object.
Arguments
source
Source object created with set_source.
Method update_source()
Update Source in the Cohort object.
Arguments
source
Source object created with set_source.
keep_steps
If `TRUE`, steps definition remains unchanged when updating source. If `FALSE` steps configuration is deleted. If vector of type integer, specified steps will remain.
run_flow
If `TRUE`, data flow is run after the operation is completed.
hook
List of hooks describing methods before/after the Cohort is created. See hooks for more details.
Method remove_step()
Remove filtering step definition
Arguments
step_id
Id of the step to remove.
run_flow
If `TRUE`, data flow is run after the operation is completed.
hook
List of hooks describing methods before/after the Cohort is created. See hooks for more details.
Method add_filter()
Add filter definition
Arguments
filter
Filter definition created with filter.
step_id
Id of the step to add the filter to. If missing, filter is added to the last step.
run_flow
If `TRUE`, data flow is run after the operation is completed.
Method update_filter()
Update filter definition
Method get_state()
Get Cohort configuration state.
Method restore()
Arguments
state
List or JSON string containing steps and filters configuration.
modifier
Function two parameters combining the previous and provided state. The returned state is then restored.
run_flow
If `TRUE`, data flow is run after the operation is completed.
hook
List of hooks describing methods before/after the Cohort is created. See hooks for more details.
Method get_data()
Get step related data
Method plot_data()
Plot filter specific data summary.
Method get_stats()
Get Cohort related statistics.
Arguments
step_id
When `filter_id` specified, `step_id` precises from which step the filter comes from. Otherwise data from specified step is used to calculate required statistics.
filter_id
If not missing, filter related data statistics are returned.
...
Specific parameters passed to filter related method.
state
Should the stats be calculated on data before ("pre") or after ("post") filtering in specified step.
Method show_help()
Show source data or filter description
Usage
Cohort$show_help(
field,
step_id,
filter_id,
modifier = getOption("cb_help_modifier", default = function(x) x)
)
Arguments
field
Name of the source description field provided as `description` argument to set_source. If missing, `step_id` and `filter_id` are used to return filter description.
step_id
Id of the filter step to return description of.
filter_id
Id of the filter to return description of.
modifier
A function taking the description as argument. The function can be used to modify its argument (convert to html, display in browser etc.).
Method get_code()
Return reproducible data filtering code.
Arguments
include_source
If `TRUE` source generating code will be included.
include_methods
Which methods definition should be included in the result.
include_action
Which action should be returned in the result. `pre_filtering`/`.post_filtering` - to include data transformation before/after filtering. s`run_binding` - data binding transformation.
modifier
A function taking data frame (storing reproducible code metadata) as an argument, and returning data frame with `expr` column which is then combined into a single expression (final result of `get_code`). See .repro_code_tweak.
mark_step
Include information which filtering step is performed.
...
Other parameters passed to tidy_source.
Method run_flow()
Trigger data calculations sequentially.
Arguments
min_step
Step id starting from the calculation will be started.
hook
List of hooks describing methods before/after the Cohort is created. See hooks for more details.
Method run_step()
Trigger data calculations for selected step.
Arguments
step_id
Id of the step for which to run data calculation.
hook
List of hooks describing methods before/after the Cohort is created. See hooks for more details.
Method bind_data()
Run data binding for selected step. See more at binding-keys.
Method update_cache()
Update filter or step cache. Caching is saving step and filter attached data statistics such as number of data rows, filter choices or frequencies.
Arguments
step_id
Id of the step for which caching should be applied. If `filter_id` is not missing, the parameter describes id of the step where filter should be found.
filter_id
Id of the filter for which caching should be applied.
state
Should caching be done on data before ("pre") or after ("post") filtering in specified step.
Method get_cache()
Return step of filter specific cache.
Arguments
step_id
Id of the step for which cached data should be returned If `filter_id` is not missing, the parameter describes id of the step where filter should be found.
filter_id
Id of the filter for which cache data should be returned.
state
Should cache be returned on data before ("pre") or after ("post") filtering in specified step.