mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2024-11-22 13:30:23 +01:00
bypassing factor field capture routine when no factor fields present
This commit is contained in:
parent
8999533098
commit
57a0538a11
@ -112,27 +112,30 @@ REDCap_split <- function(records, metadata) {
|
|||||||
fields <- rbind(fields, form_complete_fields)
|
fields <- rbind(fields, form_complete_fields)
|
||||||
|
|
||||||
# Process ".*\\.factor" fields supplied by REDCap's export data R script
|
# Process ".*\\.factor" fields supplied by REDCap's export data R script
|
||||||
factor_fields <-
|
if (any(grepl("\\.factor$", names(records)))) {
|
||||||
do.call(
|
|
||||||
"rbind",
|
|
||||||
apply(
|
|
||||||
fields,
|
|
||||||
1,
|
|
||||||
function(x, y) {
|
|
||||||
field_indices <- grepl(paste0("^", x[1], "\\.factor$"), y)
|
|
||||||
if (any(field_indices))
|
|
||||||
data.frame(
|
|
||||||
field_name = y[field_indices],
|
|
||||||
form_name = x[2],
|
|
||||||
stringsAsFactors = FALSE,
|
|
||||||
row.names = NULL
|
|
||||||
)
|
|
||||||
},
|
|
||||||
y = names(records)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
fields <- rbind(fields, factor_fields)
|
factor_fields <-
|
||||||
|
do.call(
|
||||||
|
"rbind",
|
||||||
|
apply(
|
||||||
|
fields,
|
||||||
|
1,
|
||||||
|
function(x, y) {
|
||||||
|
field_indices <- grepl(paste0("^", x[1], "\\.factor$"), y)
|
||||||
|
if (any(field_indices))
|
||||||
|
data.frame(
|
||||||
|
field_name = y[field_indices],
|
||||||
|
form_name = x[2],
|
||||||
|
stringsAsFactors = FALSE,
|
||||||
|
row.names = NULL
|
||||||
|
)
|
||||||
|
},
|
||||||
|
y = names(records)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
fields <- rbind(fields, factor_fields)
|
||||||
|
}
|
||||||
|
|
||||||
# Identify the subtables in the data
|
# Identify the subtables in the data
|
||||||
subtables <- unique(records$redcap_repeat_instrument)
|
subtables <- unique(records$redcap_repeat_instrument)
|
||||||
|
Loading…
Reference in New Issue
Block a user