Make IDs with fixed length and a prefix (e.g., S001, S002, ..., S100).
make_id(n = 100, prefix = "S", digits = 0, suffix = "")
n | the number of IDs to generate (or a vector of numbers) |
---|---|
prefix | the prefix to the number (default "S") |
digits | the number of digits to use for the numeric part. Only used if this is larger than the largest number of digits in n. |
suffix | the suffix to the number (default "") |
a vector of IDs
make_id(20, "SUBJECT_")#> [1] "SUBJECT_01" "SUBJECT_02" "SUBJECT_03" "SUBJECT_04" "SUBJECT_05" #> [6] "SUBJECT_06" "SUBJECT_07" "SUBJECT_08" "SUBJECT_09" "SUBJECT_10" #> [11] "SUBJECT_11" "SUBJECT_12" "SUBJECT_13" "SUBJECT_14" "SUBJECT_15" #> [16] "SUBJECT_16" "SUBJECT_17" "SUBJECT_18" "SUBJECT_19" "SUBJECT_20"make_id(10:30, digits = 3)#> [1] "S010" "S011" "S012" "S013" "S014" "S015" "S016" "S017" "S018" "S019" #> [11] "S020" "S021" "S022" "S023" "S024" "S025" "S026" "S027" "S028" "S029" #> [21] "S030"