Closing issue #12

test included
This commit is contained in:
Paul W. Egeler, MS, GStat 2019-07-26 17:26:33 -04:00
commit cb253af3ba
3 changed files with 37 additions and 1 deletions

View file

@ -89,6 +89,10 @@ REDCap_split <- function(records,
records <- process_user_input(records)
metadata <- process_user_input(metadata)
# Remove "tbl_df" class from metadata, if present, due to difference in
# `[.tbl_df` behavior as compared to `[.data.frame` behavior (see issue #12)
if(inherits(metadata, "tbl_df")) class(metadata) <- "data.frame"
# Get the variable names in the dataset
vars_in_data <- names(records)
@ -100,6 +104,15 @@ REDCap_split <- function(records,
stop("There are no repeating instruments in this dataset.")
}
# Remove NAs from `redcap_repeat_instrument` (see issue #12)
if(any(is.na(records$redcap_repeat_instrument))) {
records$redcap_repeat_instrument <- ifelse(
is.na(records$redcap_repeat_instrument),
"",
as.character(records$redcap_repeat_instrument)
)
}
# Standardize variable names for metadata
names(metadata) <- metadata_names