Decodes variables with single coded entries

decode_single(cohort, coding)

Arguments

cohort
  • A cohort or dataset extracted using dx extract data

coding
  • Combined coding/data dictionary generated from merge_coding_data_dict

Value

data.frame with single coded columns decoded

Examples

data(coding_dict)
data(cohort)
data(data_dict)

cdata <- merge_coding_data_dict(coding_dict, data_dict)

cohort |>
  decode_single(cdata)
#> # A tibble: 100 × 18
#>    participant.p21022 participant.p100240_i0 participant.p100240_i1
#>                 <dbl> <chr>                  <chr>                 
#>  1                 43 NA                     Yes                   
#>  2                 60 NA                     NA                    
#>  3                 53 NA                     No                    
#>  4                 62 NA                     NA                    
#>  5                 67 NA                     NA                    
#>  6                 61 NA                     NA                    
#>  7                 66 NA                     NA                    
#>  8                 56 NA                     NA                    
#>  9                 55 NA                     NA                    
#> 10                 53 NA                     NA                    
#> # ℹ 90 more rows
#> # ℹ 15 more variables: participant.p100240_i2 <chr>,
#> #   participant.p100240_i3 <chr>, participant.p100240_i4 <chr>,
#> #   participant.p1498_i0 <dbl>, participant.p1498_i1 <dbl>,
#> #   participant.p1498_i2 <dbl>, participant.p1508_i0 <chr>,
#> #   participant.p1508_i1 <chr>, participant.p1508_i2 <chr>,
#> #   participant.p41202 <chr>, participant.p31 <chr>, …