| Cohort | R Documentation |
R6 class representing Cohort object.
R6 class representing Cohort object.
Cohort object is designed to make operations on source data possible.
attributesList of Cohort attributes defined while creating a new Cohort object.
new()Create Cohort object.
Cohort$new(
source,
...,
run_flow = FALSE,
hook = list(pre = get_hook("pre_cohort_hook"), post = get_hook("post_cohort_hook"))
)sourceSource 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_flowIf 'TRUE', data flow is run after the operation is completed.
hookList of hooks describing methods before/after the Cohort is created. See hooks for more details.
The object of class 'Cohort'.
add_source()Add Source to Cohort object.
Cohort$add_source(source)
sourceSource object created with set_source.
update_source()Update Source in the Cohort object.
Cohort$update_source(
source,
keep_steps = !has_steps(source),
run_flow = FALSE,
hook = list(pre = get_hook("pre_update_source_hook"), post =
get_hook("post_update_source_hook"))
)sourceSource object created with set_source.
keep_stepsIf 'TRUE', steps definition remains unchanged when updating source. If 'FALSE' steps configuration is deleted. If vector of type integer, specified steps will remain.
run_flowIf 'TRUE', data flow is run after the operation is completed.
hookList of hooks describing methods before/after the Cohort is created. See hooks for more details.
get_source()Return Source object attached to Cohort.
Cohort$get_source()
add_step()Add filtering step definition
Cohort$add_step(
step,
run_flow = FALSE,
hook = list(pre = get_hook("pre_add_step_hook"), post = get_hook("post_add_step_hook"))
)stepStep definition created with step.
run_flowIf 'TRUE', data flow is run after the operation is completed.
hookList of hooks describing methods before/after the Cohort is created. See hooks for more details.
copy_step()Copy selected step.
Cohort$copy_step(step_id, filters, run_flow = FALSE)
step_idId of the step to be copied. If missing the last step is taken. The copied step is added as the last one in the Cohort.
filtersList of Source-evaluated filters to copy to new step.
run_flowIf 'TRUE', data flow is run after the operation is completed.
remove_step()Remove filtering step definition
Cohort$remove_step(
step_id,
run_flow = FALSE,
hook = list(pre = get_hook("pre_rm_step_hook"), post = get_hook("post_rm_step_hook"))
)step_idId of the step to remove.
run_flowIf 'TRUE', data flow is run after the operation is completed.
hookList of hooks describing methods before/after the Cohort is created. See hooks for more details.
add_filter()Add filter definition
Cohort$add_filter(filter, step_id, run_flow = FALSE)
filterFilter definition created with filter.
step_idId of the step to add the filter to. If missing, filter is added to the last step.
run_flowIf 'TRUE', data flow is run after the operation is completed.
remove_filter()Remove filter definition
Cohort$remove_filter(step_id, filter_id, run_flow = FALSE)
step_idId of the step from which filter should be removed.
filter_idId of the filter to be removed.
run_flowIf 'TRUE', data flow is run after the operation is completed.
update_filter()Update filter definition
Cohort$update_filter(step_id, filter_id, ..., active, run_flow = FALSE)
step_idId of the step where filter is defined.
filter_idId of the filter to be updated.
...Filter parameters that should be updated.
activeMark filter as active ('TRUE') or inactive ('FALSE').
run_flowIf 'TRUE', data flow is run after the operation is completed.
clear_filter()Reset filter to its default values.
Cohort$clear_filter(step_id, filter_id, run_flow = FALSE)
step_idId of the step where filter is defined.
filter_idId of the filter which should be cleared.
run_flowIf 'TRUE', data flow is run after the operation is completed.
clear_step()Reset all filters included in selected step.
Cohort$clear_step(step_id, run_flow = FALSE)
step_idId of the step where filters should be cleared.
run_flowIf 'TRUE', data flow is run after the operation is completed.
sum_up_state()Sum up Cohort configuration - Source, steps definition and evaluated data.
Cohort$sum_up_state()
get_state()Get Cohort configuration state.
Cohort$get_state(step_id, json = FALSE, extra_fields = NULL)
step_idIf provided, the selected step state is returned.
jsonIf TRUE, return state in JSON format.
extra_fieldsNames of extra fields included in filter to be added to state. Restore Cohort configuration.
restore()Cohort$restore(
state,
modifier = function(prev_state, state) {
state
},
run_flow = FALSE,
hook = list(pre = get_hook("pre_restore_hook"), post = get_hook("post_restore_hook"))
)stateList or JSON string containing steps and filters configuration.
modifierFunction two parameters combining the previous and provided state. The returned state is then restored.
run_flowIf 'TRUE', data flow is run after the operation is completed.
hookList of hooks describing methods before/after the Cohort is created. See hooks for more details.
get_data()Get step related data
Cohort$get_data(step_id, state = "post", collect = TRUE)
step_idId of the step from which to source data.
stateReturn data before ("pre") or after ("post") step filtering?
collectReturn raw data source ('FALSE') object or collected (to R memory) data ('TRUE').
plot_data()Plot filter specific data summary.
Cohort$plot_data(step_id, filter_id, ..., state = "post")
step_idId of the step where filter is defined.
filter_idId of the filter for which the plot should be returned
...Another parameters passed to filter specific method.
stateGenerate plot on data before ("pre") or after ("post") step filtering?
show_attrition()Show attrition plot.
Cohort$show_attrition(..., percent = FALSE)
...Source specific parameters required to generate attrition.
percentShould attrition changes be presented with percentage values.
get_stats()Get Cohort related statistics.
Cohort$get_stats(step_id, filter_id, ..., state = "post")
step_idWhen '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_idIf not missing, filter related data statistics are returned.
...Specific parameters passed to filter related method.
stateShould the stats be calculated on data before ("pre") or after ("post") filtering in specified step.
show_help()Show source data or filter description
Cohort$show_help(
field,
step_id,
filter_id,
modifier = getOption("cb_help_modifier", default = function(x) x)
)fieldName 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_idId of the filter step to return description of.
filter_idId of the filter to return description of.
modifierA function taking the description as argument. The function can be used to modify its argument (convert to html, display in browser etc.).
get_code()Return reproducible data filtering code.
Cohort$get_code(
include_source = TRUE,
include_methods = c(".pre_filtering", ".post_filtering", ".run_binding"),
include_action = c("pre_filtering", "post_filtering", "run_binding"),
modifier = .repro_code_tweak,
mark_step = TRUE,
...
)include_sourceIf 'TRUE' source generating code will be included.
include_methodsWhich methods definition should be included in the result.
include_actionWhich action should be returned in the result. 'pre_filtering'/'.post_filtering' - to include data transformation before/after filtering. s'run_binding' - data binding transformation.
modifierA 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_stepInclude information which filtering step is performed.
...Other parameters passed to tidy_source.
run_flow()Trigger data calculations sequentially.
Cohort$run_flow(
min_step,
hook = list(pre = get_hook("pre_run_flow_hook"), post = get_hook("post_run_flow_hook"))
)min_stepStep id starting from the calculation will be started.
hookList of hooks describing methods before/after the Cohort is created. See hooks for more details.
run_step()Trigger data calculations for selected step.
Cohort$run_step(
step_id,
hook = list(pre = get_hook("pre_run_step_hook"), post = get_hook("post_run_step_hook"))
)step_idId of the step for which to run data calculation.
hookList of hooks describing methods before/after the Cohort is created. See hooks for more details.
bind_data()Run data binding for selected step. See more at binding-keys.
Cohort$bind_data(step_id)
step_idId of the step for which to bind the data.
describe_state()Print defined steps configuration.
Cohort$describe_state()
get_step()Get selected step configuration.
Cohort$get_step(step_id)
step_idId of the step to be returned.
get_filter()Get selected filter configuration.
Cohort$get_filter(step_id, filter_id, method = function(x) x)
step_idId of the step where filter is defined.
filter_idIf of the filter to be returned.
methodCustom function taking filters list as argument.
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.
Cohort$update_cache(step_id, filter_id, state = "post")
step_idId 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_idId of the filter for which caching should be applied.
stateShould caching be done on data before ("pre") or after ("post") filtering in specified step.
get_cache()Return step of filter specific cache.
Cohort$get_cache(step_id, filter_id, state = "post")
step_idId 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_idId of the filter for which cache data should be returned.
stateShould cache be returned on data before ("pre") or after ("post") filtering in specified step.
list_active_filters()List active filters included in selected step.
Cohort$list_active_filters(step_id)
step_idId of the step where filters should be found.
last_step_id()Return id of the last existing step in Cohort.
Cohort$last_step_id()
modify()Helper method enabling to run non-standard operation on Cohort object.
Cohort$modify(modifier)
modifierFunction of two arguments 'self' and 'private'.
clone()The objects of this class are cloneable with this method.
Cohort$clone(deep = FALSE)
deepWhether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.