Upon first use, an ID column will be mutated to the given data set according to the specified subject column.
For each subsequent use, IDs will be assigned to match the previous derived data set. If new subjects are found in the data, they will be assigned a unique value not present in the previous derived data (starting at the maximum of the previous IDs plus 1).
assign_id(.data, .previously_derived_path = NULL, .subject_col = "USUBJID")
A data.frame to have ID column mutated onto.
A string containing the file path of the previous derived data set
A character string containing the column name of the subject identifying column in the data
Theoph2 <-
Theoph %>%
dplyr::mutate(USUBJID = paste0("Subject-", Subject)) %>%
dplyr::select(-Subject)
df_with_id <-
assign_id(
Theoph2,
.subject_col = "USUBJID"
)
#> ┌ ID Summary ──────────────────────────────────────────┐
#> │ │
#> │ Number of subjects detected and assigned IDs: 12 │
#> │ │
#> └──────────────────────────────────────────────────────┘