%%capture
%%R
metadata <- redcap_metadata_read(
redcap_uri = url,
token = token
)$data11 Metadata
REDCap metadata can be exported via the API.
The REDCap metadata will contain all the fields in your REDCap project excluding:
- Any survey timestamp or survey identifier fields (automatically generated when a form is enabled as a survey).
- Any fields that are part of the unique key aside from the
record_id(redcap_event_name,redcap_repeat_instrumentandredcap_repeat_instance). - Any
<form_name>_completefields. - Checkbox fields are exported as one field per checkbox (not in the wide format as they appear in the data export).
In REDCap the record_id field can be renamed. The first field in the exported metadata will always be record_id or the ‘record_id’ equivalent field.
redcap_metadata_read()
export_metadata()
project.export_metadata(format_type="df").head(10)| form_name | section_header | field_type | field_label | select_choices_or_calculations | field_note | text_validation_type_or_show_slider_number | text_validation_min | text_validation_max | identifier | branching_logic | required_field | custom_alignment | question_number | matrix_group_name | matrix_ranking | field_annotation | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| field_name | |||||||||||||||||
| record_id | demographics | NaN | text | Record ID | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| first_name | demographics | Personal Information | text | First Name | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| last_name | demographics | NaN | text | Last Name | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| phone_num | demographics | NaN | text | Phone Number | NaN | NaN | phone | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| zip_code | demographics | NaN | text | ZIP Code | NaN | NaN | integer | 10001.0 | 99999 | y | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| dob | demographics | NaN | text | Date of birth | NaN | NaN | date_mdy | NaN | NaN | y | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| age | demographics | NaN | calc | Age (years) | rounddown(datediff([dob],'today','y')) | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| ethnicity | demographics | NaN | radio | Ethnicity | 0, Hispanic or Latino|1, NOT Hispanic or Latin... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | LH | NaN | NaN | NaN | NaN |
| race | demographics | NaN | dropdown | Race | 0, American Indian/Alaska Native|1, Asian|2, N... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| gender | demographics | NaN | radio | Gender | 0, Female|1, Male|2, Other|3, Prefer not to say | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |