Rewrites the labelling of
checkbox variables from
Checked/Unchecked to Yes/No (or some other user-specified labelling).
A data frame, presumably retrieved from REDCap, though not a strict requirement.
Optional character vector of variables to convert. If left
missing, all of the variables in
A character vector to be passed to
A character vector of labels to replace the values in
For convenience, if the user would prefer to reverse the
order of the elements in
checkbox variables are not identified using the metadata
from the REDCap database. Instead, variables are scanned, and those
variables in which every value is in
levels are assumed to be
Realistically, this could be used to relabel any set of factors with
identical labels, regardless of the data source. The number of labels is
not limited, but
labels should have the same length.
The actual code to perform this is not particularly difficult
df[checkbox] <- lapply(df[checkbox], factor, levels=levels, labels=labels)),
checkbox variables are common enough in REDCap
(and the Checked/Unchecked scheme so unpalatable) that a quick way to
replace the labels was highly desirable
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.