knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of redcapdd is to generate properly formatted data dictionaries for upload to REDCap.
devtools::install_github("Sage-Bionetworks/redcapdd")
You can create a new field with create_fields()
. The result will have all of
the columns required in a REDCap data dictionary.
When called with no arguments, create_fields()
provides a one-row data frame
containing all NAs.
library("redcapdd") create_fields()
You can provide as much information as you want to populate the field;
create_fields()
will fill out the rest of the columns with NAs.
x <- list( `Variable / Field Name` = "patient_name", `Field Label` = "Patient name", `Identifier?` = "y" ) create_fields(x)
There are a number of aliases to create_fields()
that support the creation of
specific field types. These include create_checkbox_field()
,
create_text_field()
, and others. See ?create_fields
for more information.
redcapdd also supports chaining operations with %>%
and the add_field()
function. Like create_fields()
, add_field()
has aliases for different field
types.
create_dd_template() %>% add_text_field( `Variable / Field Name` = "patient_name", `Field Label` = "Patient name", `Identifier?` = "y" ) %>% add_truefalse_field( `Variable / Field Name` = "given_birth", `Field Label` = "Patient has given birth?" )
Certain field types such as dropdown, radio, and checkbox can take multiple
options in the Choices, Calculations, OR Slider Labels
column. These options
need to be in a specific format to be accepted by REDCap's data dictionary
validator: 1, option1 | 2, option2
and so on. You can create a string in this
format from a character vector with the create_choices()
function.
x <- c("red", "green", "blue") create_choices(x)
write_dd()
will export your data dictionary with the correct fields quoted.
Some must be quoted, but others cannot be or the REDCap validator will complain
that the empty strings are invalid values; write_dd()
takes care of this for
you.
dd <- create_fields(x) write_dd(dd, "data_dictionary.csv")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.