From 0b04c8a61d9a5b9cf25f0d065794c40067ebba04 Mon Sep 17 00:00:00 2001 From: "Egeler, Paul W" Date: Mon, 4 Jun 2018 20:51:57 -0400 Subject: [PATCH] moving instrument status fields ahead of checkboxes and factors --- R/R/REDCap_split.r | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/R/R/REDCap_split.r b/R/R/REDCap_split.r index 83d4faf..0426321 100644 --- a/R/R/REDCap_split.r +++ b/R/R/REDCap_split.r @@ -72,6 +72,16 @@ REDCap_split <- function(records, metadata) { c("field_name", "form_name") ] + # Process instrument status fields + form_names <- unique(metadata$form_name) + form_complete_fields <- data.frame( + field_name = paste0(form_names, "_complete"), + form_name = form_names, + stringsAsFactors = FALSE + ) + + fields <- rbind(fields, form_complete_fields) + # Process checkbox fields if (any(metadata$field_type == "checkbox")) { @@ -101,16 +111,6 @@ REDCap_split <- function(records, metadata) { } - # Process form_complete fields - form_names <- unique(metadata$form_name) - form_complete_fields <- data.frame( - field_name = paste0(form_names, "_complete"), - form_name = form_names, - stringsAsFactors = FALSE - ) - - fields <- rbind(fields, form_complete_fields) - # Process ".*\\.factor" fields supplied by REDCap's export data R script if (any(grepl("\\.factor$", names(records)))) { @@ -135,6 +135,7 @@ REDCap_split <- function(records, metadata) { ) fields <- rbind(fields, factor_fields) + } # Identify the subtables in the data