Skip to contents

Step recode

Usage

step_recode(
  svy = survey_empty(),
  new_var,
  ...,
  .default = NA_character_,
  .name_step = NULL,
  ordered = FALSE,
  use_copy = use_copy_default(),
  comment = "Recode step",
  .to_factor = FALSE,
  .level = "auto"
)

Arguments

svy

Survey object or RotativePanelSurvey

new_var

Character of string of the new variable to create

...

A sequence of two-sided formulas. The left hand side (LHS) determines which values match this case. The right hand side (RHS) provides the replacement value. The LHS inputs must evaluate to logical vectors. The RHS inputs will be coerced to their common type.All inputs will be recycled to their common size. That said, we encourage all LHS inputs to be the same size. Recycling is mainly useful for RHS inputs, where you might supply a size 1 input that will be recycled to the size of the LHS inputs.

.default

Value to replace if no match is found

.name_step

Character name of the step identify the step in the survey object, is the name of the step is not provided it will be created automatically

ordered

Logical, if TRUE the new variable will be ordered

use_copy

Logical, if its FALSE adds the new variables to reference object like data.table, if it is TRUE adds the new variables to a new object

comment

String to add metadata information to the stap compute compatible with Markdown syntax

.to_factor

Logical, if TRUE the new variable will be converted to factor

.level

String use for Rotative_Panel_survey object indicating data to use, level options available; 'implantation' or 'follow-up'

Value

Survey or Rotative_Panel_Survey object