r-pkg: preserving order of columns in output tables

This commit is contained in:
Egeler, Paul W 2018-06-06 18:17:57 -04:00
parent fc1cad40be
commit 91d9e8e8dd

View File

@ -159,12 +159,12 @@ REDCap_split <- function(records, metadata) {
if (i == "") {
out_fields <- fields[!fields[,2] %in% subtables, 1]
out_fields <- which(vars_in_data %in% fields[!fields[,2] %in% subtables, 1])
out[[which(names(out) == "")]] <- out[[which(names(out) == "")]][out_fields]
} else {
out_fields <- c(repeat_instrument_fields, fields[fields[,2] == i, 1])
out_fields <- which(vars_in_data %in% c(repeat_instrument_fields, fields[fields[,2] == i, 1]))
out[[i]] <- out[[i]][out_fields]
}