You might be in the situation, that you have a dataset in a file, that you want to move to REDCap. Here I will try to walk through the steps of creating a database from a given dataset.
3.0.1 Create a data dictionary
Import the dataset
require(dplyr)
Loading required package: dplyr
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
# Using rownames as index and reordering to put record_id first (for REDCap)ds <- iris %>%mutate(record_id=rownames(.)) %>%select(record_id,everything(.))
3.0.2 Specify variable names etc.
Have a look at the demonstration file below for inspiration.
Note the different Field.Type’s used and Choices... , called labels. Each label will have a raw value. This is performed with a small script.
For radio buttons, I have written the different options to choose from. For variables with a score to choose from, I have written the scores, and these variables and only these variables are named something with “_score”. Variables with binary or other types of outcome, I have written the label.
# I enjoy thoughtful variable namingdd <-data.frame(matrix(nrow =ncol(ds),ncol=ncol(dd_demo)))colnames(dd) <-colnames(dd_demo)dd$Variable...Field.Name <-colnames(ds)str(ds)