camr_add_codebook_entry | R Documentation |
Function to update the attributes for a column in a data frame to contain a codebook entry. This ensures easy portability (at least within the framework of R) of the codebook for a data set.
camr_add_codebook_entry(
dtf,
variable,
description = "",
category = "",
data_type = "",
subcategory = "",
values_and_labels = "",
inventory = "",
units_of_measurement = "",
descriptive_summary = "",
codes_for_missing_data = NULL,
deidentified = "FALSE",
collected_over = "",
created_from = "",
data_quality_checks = "",
notes = "",
custom_category = NULL,
custom_data_type = NULL,
custom_subcategory = NULL,
missing_attribute_label = "missing",
digits = 2,
add_missing_to_attr = NULL,
non_standard = TRUE
)
camr_ace(...)
dtf |
A data frame, preferably one using standardized naming conventions for columns (see camr_column_abbreviations). |
variable |
The column name for the variable whose attributes should be updated to include a codebook entry. Non-standard evaluation possible. |
description |
A character string, a brief human-readable description of what the variable is. |
category |
An optional character string, the category label for the variable. If left blank, the function automatically determines the category via camr_column_abbreviations. |
data_type |
An optional character string, the data type label for the variable. If left blank, the function automatically determines the data type via camr_column_abbreviations. |
subcategory |
An optional character string, the subcategory label for the variable. If left blank, the function automatically determines the subcategory via camr_column_abbreviations. |
values_and_labels |
Either the empty character set or
a named list of two vectors, (1) |
inventory |
Either (1) output from the
camr_inventories function, (2) the empty character
set, or (3) a named list of two vectors, where |
units_of_measurement |
A character string, the units of measurement for the variable. |
descriptive_summary |
Either the empty character set or
a named list of two vectors, (1) |
codes_for_missing_data |
An optional vector with
codes for missing data. If |
deidentified |
Either |
collected_over |
Either the empty character set or
a named list of two vectors, (1) |
created_from |
An optional character vector, the original REDCap variables from which the variable was created. |
data_quality_checks |
An optional character string, notes on any data quality checks relevant to the variable. |
notes |
An optional character vector, any additional notes to include in the codebook entry. |
custom_category |
An optional matrix with two columns, 'Abbr' and 'Label', for custom abbreviations and labels for variable categories. |
custom_data_type |
An optional matrix with two columns, 'Abbr' and 'Label', for custom abbreviations and labels for data types. |
custom_subcategory |
An optional matrix with two columns, 'Abbr' and 'Label', for custom abbreviations and labels for variable subcategories. |
missing_attribute_label |
A character string, the name of the element in the list of attributes containing codes for missing data. |
digits |
The number of decimal places to round to for the descriptive summaries. |
add_missing_to_attr |
An optional logical value;
if |
non_standard |
A logical value; if |
The data frame dtf
, with the attributes for
the column specified by variable
updated to
contain a data frame of additional class
codebook_entry
.
Kevin Potter
data( "example_CAM_data_set" )
dtf <- example_CAM_data_set
# Add codebook entry to data frame
dtf <- dtf |>
camr_add_codebook_entry(
IDS.INT.Screening,
description = "Identifier assigned at screening session"
)
dtf |> camr_pull_codebook_entry( IDS.INT.Screening )
dtf <- dtf |>
camr_add_codebook_entry(
IDS.CHR.Participant,
"Identifier assigned at enrollment"
)
dtf |> camr_pull_codebook_entry( IDS.CHR.Participant )
dtf <- dtf |>
camr_add_codebook_entry(
INV.INT.HADS_anxiety,
inventory = camr_inventories( "HADS", "Anxiety" ),
descriptive_summary = "continuous",
collected_over = camr_ice(
"combine",
dtf |> camr_collected_over( INV.INT.HADS_anxiety, SSS.CHR.Session ),
dtf |> camr_collected_over( INV.INT.HADS_anxiety, SSS.CHR.Event )
)
)
dtf |> camr_pull_codebook_entry( INV.INT.HADS_anxiety )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.