Skip to contents

Define the data coding scheme for a variable

Usage

code(variable, levels, labels)

Arguments

variable

Name of the variable

levels

Vector specifying the factor levels

labels

Vector specifying the factor labels

Value

A tibble with three columns and one row per factor level

Examples

  code("SEX", levels = c(0, 1), labels = c("Male", "Female"))
#> # A tibble: 2 × 3
#>   variable level label 
#>   <chr>    <dbl> <chr> 
#> 1 SEX          0 Male  
#> 2 SEX          1 Female