This utility function reorders the data dictionary so that SUBJECT_ID comes first.
Details
SUBJECT_ID is required to be the first column of the data set and first variable listed in the data dictionary.
Examples
data(ExampleQ)
head(DD.dict.Q)
#> # A tibble: 6 × 22
#> VARNAME VARDESC DOCFILE TYPE UNITS MIN MAX RESOLUTION COMMENT1 COMMENT2
#> <chr> <chr> <lgl> <chr> <chr> <dbl> <dbl> <lgl> <lgl> <lgl>
#> 1 SAMPLE_ID Sample… NA inte… NA NA NA NA NA NA
#> 2 AGE Age at… NA inte… years NA NA NA NA NA
#> 3 SEX Sex as… NA inte… NA 0 1 NA NA NA
#> 4 SUBJECT_… Partic… NA inte… NA NA NA NA NA NA
#> 5 PREGNANT Pregna… NA inte… NA 0 1 NA NA NA
#> 6 HEIGHT Height… NA deci… cm NA NA NA NA NA
#> # ℹ 12 more variables: VARIABLE_SOURCE <lgl>, SOURCE_VARIABLE_ID <lgl>,
#> # VARIABLE_MAPPING <lgl>, UNIQUEKEY <lgl>, COLLINTERVAL <lgl>, ORDER <lgl>,
#> # VALUES <chr>, ...18 <chr>, ...19 <chr>, ...20 <chr>, ...21 <chr>,
#> # ...22 <chr>
DD.dict.updated <- id_first_dict(DD.dict.Q)
head(DD.dict.updated)
#> # A tibble: 6 × 22
#> VARNAME VARDESC DOCFILE TYPE UNITS MIN MAX RESOLUTION COMMENT1 COMMENT2
#> <chr> <chr> <lgl> <chr> <chr> <dbl> <dbl> <lgl> <lgl> <lgl>
#> 1 SUBJECT_… Partic… NA inte… NA NA NA NA NA NA
#> 2 SAMPLE_ID Sample… NA inte… NA NA NA NA NA NA
#> 3 AGE Age at… NA inte… years NA NA NA NA NA
#> 4 SEX Sex as… NA inte… NA 0 1 NA NA NA
#> 5 PREGNANT Pregna… NA inte… NA 0 1 NA NA NA
#> 6 HEIGHT Height… NA deci… cm NA NA NA NA NA
#> # ℹ 12 more variables: VARIABLE_SOURCE <lgl>, SOURCE_VARIABLE_ID <lgl>,
#> # VARIABLE_MAPPING <lgl>, UNIQUEKEY <lgl>, COLLINTERVAL <lgl>, ORDER <lgl>,
#> # VALUES <chr>, ...18 <chr>, ...19 <chr>, ...20 <chr>, ...21 <chr>,
#> # ...22 <chr>