Skip to contents

This utility function reorders the data set so that SUBJECT_ID comes first.

Usage

id_first_data(DS.data)

Arguments

DS.data

Data set.

Value

Updated data set with SUBJECT_ID as first column.

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(DS.data.Q)
#>   SAMPLE_ID SUBJECT_ID REACT AGE SEX PREGNANT     HEIGHT  WEIGHT         BMI
#> 1      1001          1    40  33   0    -4444   163.5000    54.4    20.34995
#> 2      1002          2    45  45   1        0   159.3369    93.2    36.70990
#> 3      1003          3    55  34   0    -4444   185.0000    95.0    27.75749
#> 4     -9999          4    56  55   0    -4444   171.5000    85.7    29.13752
#> 5      1005          5    64  45   0    -4444   180.0000   101.4    31.29630
#> 6      1006          6 -9999  46   1        0 -9999.0000 -9999.0 -9999.00000
#>   OBESITY    ABD_CIRC   HIP_CIRC ABD_SKF SUP_SKF RESIST CUFFSIZE BP_SYSTOLIC
#> 1       0   116.08677   119.2750      28      23    340        0         120
#> 2       1   110.39444   115.8551      24      27    354        3         110
#> 3       0   104.29832   104.4375      29      25    358        1         106
#> 4       0   121.77705   118.4763      51      44    389        1         158
#> 5       1    84.14132   104.6367      42      25    356        2         169
#> 6   -9999 -9999.00000 -9999.0000   -9999   -9999  -9999        0         105
#>   BP_DIASTOLIC HTN SMOKING_HX LENGTH_SMOKING_YEARS HEART_RATE PHYSICAL_ACTIVITY
#> 1           80   0          0              -4444.0         50               360
#> 2           60   0      -9999              -4444.0         54                 0
#> 3           50   0          1                  1.5         75               100
#> 4           95   1          0              -4444.0         90               180
#> 5          100   1          1                 14.0         85             -9999
#> 6           40   0          1                 25.0         72               180
#>   HX_DM HX_STROKE HX_ANXIETY HX_DEPRESSION SOCIAL_SUPPORT PERCEIVED_CONFLICT
#> 1     0         0          1             1              1                 25
#> 2     1         0          0             0              5                 25
#> 3 -9999         0      -9999         -9999              4                 24
#> 4     1         0          0             0              2                 10
#> 5     1     -9999          0             0              3                  5
#> 6     0         0          0             0              4                  1
#>   PERCEIVED_HEALTH
#> 1               10
#> 2                4
#> 3                8
#> 4                5
#> 5                6
#> 6                7
DS.data.updated <- id_first_data(DS.data.Q)
head(DS.data.updated)
#>   SUBJECT_ID SAMPLE_ID REACT AGE SEX PREGNANT     HEIGHT  WEIGHT         BMI
#> 1          1      1001    40  33   0    -4444   163.5000    54.4    20.34995
#> 2          2      1002    45  45   1        0   159.3369    93.2    36.70990
#> 3          3      1003    55  34   0    -4444   185.0000    95.0    27.75749
#> 4          4     -9999    56  55   0    -4444   171.5000    85.7    29.13752
#> 5          5      1005    64  45   0    -4444   180.0000   101.4    31.29630
#> 6          6      1006 -9999  46   1        0 -9999.0000 -9999.0 -9999.00000
#>   OBESITY    ABD_CIRC   HIP_CIRC ABD_SKF SUP_SKF RESIST CUFFSIZE BP_SYSTOLIC
#> 1       0   116.08677   119.2750      28      23    340        0         120
#> 2       1   110.39444   115.8551      24      27    354        3         110
#> 3       0   104.29832   104.4375      29      25    358        1         106
#> 4       0   121.77705   118.4763      51      44    389        1         158
#> 5       1    84.14132   104.6367      42      25    356        2         169
#> 6   -9999 -9999.00000 -9999.0000   -9999   -9999  -9999        0         105
#>   BP_DIASTOLIC HTN SMOKING_HX LENGTH_SMOKING_YEARS HEART_RATE PHYSICAL_ACTIVITY
#> 1           80   0          0              -4444.0         50               360
#> 2           60   0      -9999              -4444.0         54                 0
#> 3           50   0          1                  1.5         75               100
#> 4           95   1          0              -4444.0         90               180
#> 5          100   1          1                 14.0         85             -9999
#> 6           40   0          1                 25.0         72               180
#>   HX_DM HX_STROKE HX_ANXIETY HX_DEPRESSION SOCIAL_SUPPORT PERCEIVED_CONFLICT
#> 1     0         0          1             1              1                 25
#> 2     1         0          0             0              5                 25
#> 3 -9999         0      -9999         -9999              4                 24
#> 4     1         0          0             0              2                 10
#> 5     1     -9999          0             0              3                  5
#> 6     0         0          0             0              4                  1
#>   PERCEIVED_HEALTH
#> 1               10
#> 2                4
#> 3                8
#> 4                5
#> 5                6
#> 6                7