Skip to contents

The Step class is used to define and manage individual steps in a survey workflow. Each step can include operations such as recoding variables, computing new variables, or validating dependencies.

Details

The Step class is part of the survey workflow system and is designed to encapsulate all the information and operations required for a single step in the workflow. Steps can be chained together to form a complete workflow.

Public fields

name

The name of the step.

edition

The edition of the survey associated with the step.

survey_type

The type of survey associated with the step.

type

The type of operation performed by the step (e.g., "compute", "recode").

new_var

The name of the new variable created by the step, if applicable.

exprs

A list of expressions defining the step's operations.

call

The function call associated with the step.

svy_before

The survey object before the step is applied.

default_engine

The default engine used for processing the step.

depends_on

A list of variables that the step depends on.

comments

Comments or notes about the step.

bake

A logical value indicating whether the step has been executed.

expressions

Optional list of AST expressions used by this step (for AST-backed steps).

names

Optional character vector with the variable names associated to expressions.

ast_info

Optional list with AST metadata (original expressions, optimized versions, dependencies, flags).

Methods

Public methods


Method new()

Create a new Step object

Usage

Step$new(
  name,
  edition,
  survey_type,
  type,
  new_var,
  exprs,
  call,
  svy_before,
  default_engine,
  depends_on,
  comments = NULL,
  bake = !lazy_default(),
  comment = NULL,
  expressions = NULL,
  names = NULL,
  ast_info = NULL
)

Arguments

name

The name of the step.

edition

The edition of the survey associated with the step.

survey_type

The type of survey associated with the step.

type

The type of operation performed by the step (e.g., "compute" or "recode").

new_var

The name of the new variable created by the step, if applicable.

exprs

A list of expressions defining the step's operations.

call

The function call associated with the step.

svy_before

The survey object before the step is applied.

default_engine

The default engine used for processing the step.

depends_on

A list of variables that the step depends on.

comments

Comments or notes about the step.

bake

A logical value indicating whether the step has been executed.

comment

Optional alias of comments for backwards compatibility.

expressions

Optional list of AST expressions for AST compute steps.

names

Optional character vector of variable names for AST compute steps.

ast_info

Optional list with AST-related metadata for this step.


Method clone()

The objects of this class are cloneable with this method.

Usage

Step$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

step <- Step$new(
  name = "example_step",
  edition = "2023",
  survey_type = "example_survey",
  type = "compute",
  new_var = "example_var",
  exprs = list(a = 1, b = 2),
  call = NULL,
  svy_before = NULL,
  default_engine = NULL,
  depends_on = list("var1", "var2"),
  comments = "Example step",
  bake = FALSE
)
print(step)
#> <Step>
#>   Public:
#>     ast_info: NULL
#>     bake: FALSE
#>     call: NULL
#>     clone: function (deep = FALSE) 
#>     comments: Example step
#>     default_engine: NULL
#>     depends_on: list
#>     edition: 2023
#>     expressions: NULL
#>     exprs: list
#>     initialize: function (name, edition, survey_type, type, new_var, exprs, call, 
#>     name: example_step
#>     names: NULL
#>     new_var: example_var
#>     survey_type: example_survey
#>     svy_before: NULL
#>     type: compute