term_to_code()
maps SDTM terminology terms to respective C-codes. For
mapping terms referring to codelists, use cl_term_to_code()
instead.
Arguments
- term
A SDTM controlled terminology term (as expected in submissions).
- code_list
Parent codelist code.
Value
A character vector of SDTM controlled terminology C-codes. The number
of elements returned matches the number of elements in term
, i.e. there
is a one-to-one correspondence between input and output. Invalid codes in
term
are mapped to NA
.
See also
See code_to_term()
for the inverse operation.
Examples
term_to_code(term = "TENMW101", code_list = "C141657")
#> [1] "C174106"
# Both `term` and `code_list` are vectorized. `code_list` will be recycled
# to match `term` number of elements.
term_to_code(term = c("TENMW101", "TENMW102"), code_list = "C141657")
#> [1] "C174106" "C141700"
# You may mix codelists as long as `term` and `code_list` have the same
# number of elements; they will be matched element-wise.
term_to_code(
term = c("TENMW101", "TENMW102", "TENMW1-Test Grade"),
code_list = c("C141657", "C141657", "C141656")
)
#> [1] "C174106" "C141700" "C141701"
# Invalid terms (e.g. `"Gambelas"`) map to `NA`.
term_to_code(term = c("TENMW101", "TENMW102", "Gambelas"), code_list = "C141657")
#> [1] "C174106" "C141700" NA