View source: R/REDCap_factors.R
| REDCap_factors | R Documentation |
Applies factor levels and labels using REDCap dictionary definitions for
radio and checkbox fields (configurable via radio_value).
REDCap_factors(
data,
lookup,
var_col = `Variable / Field Name`,
type_col = `Field Type`,
levels_col = `Choices, Calculations, OR Slider Labels`,
radio_value = c("checkbox", "radio"),
warn = TRUE
)
data |
Data frame containing REDCap records. |
lookup |
Data frame containing variable metadata. |
var_col |
Unquoted column in |
type_col |
Unquoted column in |
levels_col |
Unquoted column in |
radio_value |
Character vector of field types to convert. |
warn |
Logical; warn when variables are in |
data with selected columns converted to factors.
dict_path <- system.file("ext", "DataDictionary_chronotype.csv",
package = "melidosData"
)
dict <- utils::read.csv(dict_path, check.names = FALSE)
dict <- REDCap_codebook_prepare(dict, form.filter = "mctq")
chronotype_with_factors <-
REDCap_factors(
data = REDCap_example_chronotype,
lookup = dict
)
chronotype_with_factors$mctq_work_travel
#original:
REDCap_example_chronotype$mctq_work_travel
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.