Create a character vector of values to be used as labels for a factor.
Arguments
- t
A non-empty numeric vector of unique, finite elements in ascending order.
- visit
A single character string specifying the prefix to add to
t.- baseline
A single character string to use for the first timepoint's label. Alternatively, set to
NULLso that all timepoints will have the prefix specified byvisit.- pad
The character to use to pad between
visitandtso that the places oftare aligned. Alternatively, set toNULLso thattis automatically converted tocharacterwithout special formatting. This can result in numbers in labels not being aligned or not being in "alphabetical" order.
Details
Places visit as a prefix before the values of t. If pad is not NULL,
the values of t are first formatted so that their places are aligned, and
they are left-padded with zeros.
If baseline is not NULL it is used as the first label regardless of the
value of t[1].
Uses make.unique(sep = "_") in case any elements are identical after
formatting.
Examples
make_visit_labels(c(0, 5, 13, 101))
#> [1] "BASELINE" "VIS005" "VIS013" "VIS101"
make_visit_labels(c(0, 5.23453, 13, 101.4))
#> [1] "BASELINE" "VIS005.23453" "VIS013.00000" "VIS101.40000"
make_visit_labels(c(0, 5.23453, 13, 101.4), baseline = NULL, pad = " ")
#> [1] "VIS 0.00000" "VIS 5.23453" "VIS 13.00000" "VIS101.40000"
make_visit_labels(c(0, 5.23453, 13, 101.4), visit = "Week", pad = NULL)
#> [1] "BASELINE" "Week5.23453" "Week13" "Week101.4"