Skip to content

Commit

Permalink
1st draft of superwide 3
Browse files Browse the repository at this point in the history
before stealing flavor from @januz's actual dictionary

ref #360
  • Loading branch information
wibeasley committed Nov 2, 2021
1 parent 8bc7333 commit 189feda
Show file tree
Hide file tree
Showing 4 changed files with 35,070 additions and 0 deletions.
1 change: 1 addition & 0 deletions inst/misc/example.credentials
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ redcap_uri,username,project_id,token,comment
"https://bbmc.ouhsc.edu/redcap/api/","myusername","1490","457C24AB91B7FCF5B1A7DA67E70E24C7","simple write metadata"
"https://bbmc.ouhsc.edu/redcap/api/","myusername","2545","0BF11B9CB01F0B8F8EE203B7E07DEFD9","DAG Write"
"https://bbmc.ouhsc.edu/redcap/api/","myusername","2593","1C31398F332FCACA4C0A7B93B18D5CD4","super-wide #2--5,785 columns"
"https://bbmc.ouhsc.edu/redcap/api/","myusername","2597","5C1526186C4D04AE0A0630743E69B53C","super-wide #3--35,000 columns"
46 changes: 46 additions & 0 deletions inst/test-data/super-wide-3/generate-dictionary.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

variable_count <- 35004L # A multiple of the field types
field_types <- c("text", "radio", "checkbox", "notes", "text", "descriptive")
choices <- c("", "1, Yup | 2, Nope | 3, Other", "1, Yup | 2, Nope | 3, Other", "", "", "")
validations <- c("", "", "", "", "date_ymd", "")

cycle_length <- length(field_types)
cycle_count <- variable_count %/% cycle_length

section_header_template <- '<div class="rich-text-field-label"><p style="text-align: center;"><span style="color: #000080;">Please answer the following questions in form_%04i</span></p></div>'

ds <-
tibble::tibble(
`Variable / Field Name` = c("record_id", sprintf("variable_%05i", 1L + seq_len(variable_count - 1L))),
`Form Name` = NA_character_,
`Section Header` = NA_character_,
`Field Type` = rep(field_types, times = cycle_count),
`Field Label` = NA_character_,
`Choices, Calculations, OR Slider Labels` = rep(choices, times = cycle_count),
`Field Note` = NA_character_,
`Text Validation Type OR Show Slider Number` = rep(validations, times = cycle_count),
`Text Validation Min` = "",
`Text Validation Max` = "",
`Identifier?` = NA_character_,
`Branching Logic (Show field only if...)` = "",
`Required Field?` = NA_character_,
`Custom Alignment` = NA_character_,
`Question Number (surveys only)` = "",
`Matrix Group Name` = "",
`Matrix Ranking?` = "",
`Field Annotation` = "",
variable_index = seq_len(variable_count) # Helper variable
) |>
dplyr::mutate(
`Form Name` = sprintf("form_%04i", variable_index %/% cycle_length + 1L),
`Section Header` = dplyr::if_else(variable_index %% cycle_length == 0L, sprintf(section_header_template, variable_index %/% cycle_length + 1L), ""),
`Field Label` = sprintf("Long description for variable %s", `Variable / Field Name`),
`Field Note` = sprintf("Field note %s", `Variable / Field Name`),
`Identifier?` = dplyr::if_else(variable_index %% 4 == 0L, "y", ""),
`Required Field?` = dplyr::if_else(variable_index %% 2 == 0L & `Field Type` != "descriptive", "y", ""),
`Custom Alignment` = dplyr::if_else(variable_index %% 5 == 0L, "RH", ""),
)

ds$variable_index <- NULL # Drop before writing to disk.

readr::write_csv(ds, "inst/test-data/super-wide-3/super-wide-3-dictionary.csv")
Loading

0 comments on commit 189feda

Please sign in to comment.