mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2025-04-02 22:22:33 +02:00
allows not splitting data
This commit is contained in:
parent
2e1e7822a4
commit
0b5319f647
@ -26,7 +26,7 @@
|
|||||||
#' \link[REDCapCAST]{fct_drop} to drop empty levels.
|
#' \link[REDCapCAST]{fct_drop} to drop empty levels.
|
||||||
#'
|
#'
|
||||||
#' @param split_forms Whether to split "repeating" or "all" forms, default is
|
#' @param split_forms Whether to split "repeating" or "all" forms, default is
|
||||||
#' all.
|
#' all. Give "none" to export native semi-long REDCap format
|
||||||
#' @param ... passed on to \link[REDCapR]{redcap_read}
|
#' @param ... passed on to \link[REDCapR]{redcap_read}
|
||||||
#'
|
#'
|
||||||
#' @return list of instruments
|
#' @return list of instruments
|
||||||
@ -43,10 +43,10 @@ read_redcap_tables <- function(uri,
|
|||||||
events = NULL,
|
events = NULL,
|
||||||
forms = NULL,
|
forms = NULL,
|
||||||
raw_or_label = c("raw", "label", "both"),
|
raw_or_label = c("raw", "label", "both"),
|
||||||
split_forms = "all",
|
split_forms = c("all", "repeating", "none"),
|
||||||
...) {
|
...) {
|
||||||
|
|
||||||
raw_or_label <- match.arg(raw_or_label, c("raw", "label", "both"))
|
raw_or_label <- match.arg(raw_or_label, c("raw", "label", "both"))
|
||||||
|
split_forms <- match.arg(split_forms)
|
||||||
|
|
||||||
# Getting metadata
|
# Getting metadata
|
||||||
m <-
|
m <-
|
||||||
@ -56,8 +56,10 @@ read_redcap_tables <- function(uri,
|
|||||||
fields_test <- fields %in% c(m$field_name, paste0(unique(m$form_name), "_complete"))
|
fields_test <- fields %in% c(m$field_name, paste0(unique(m$form_name), "_complete"))
|
||||||
|
|
||||||
if (any(!fields_test)) {
|
if (any(!fields_test)) {
|
||||||
print(paste0("The following field names are invalid: ",
|
print(paste0(
|
||||||
paste(fields[!fields_test], collapse = ", "), "."))
|
"The following field names are invalid: ",
|
||||||
|
paste(fields[!fields_test], collapse = ", "), "."
|
||||||
|
))
|
||||||
stop("Not all supplied field names are valid")
|
stop("Not all supplied field names are valid")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,8 +69,10 @@ read_redcap_tables <- function(uri,
|
|||||||
forms_test <- forms %in% unique(m$form_name)
|
forms_test <- forms %in% unique(m$form_name)
|
||||||
|
|
||||||
if (any(!forms_test)) {
|
if (any(!forms_test)) {
|
||||||
print(paste0("The following form names are invalid: ",
|
print(paste0(
|
||||||
paste(forms[!forms_test], collapse = ", "), "."))
|
"The following form names are invalid: ",
|
||||||
|
paste(forms[!forms_test], collapse = ", "), "."
|
||||||
|
))
|
||||||
stop("Not all supplied form names are valid")
|
stop("Not all supplied form names are valid")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,8 +86,10 @@ read_redcap_tables <- function(uri,
|
|||||||
event_test <- events %in% unique(arm_event_inst$data$unique_event_name)
|
event_test <- events %in% unique(arm_event_inst$data$unique_event_name)
|
||||||
|
|
||||||
if (any(!event_test)) {
|
if (any(!event_test)) {
|
||||||
print(paste0("The following event names are invalid: ",
|
print(paste0(
|
||||||
paste(events[!event_test], collapse = ", "), "."))
|
"The following event names are invalid: ",
|
||||||
|
paste(events[!event_test], collapse = ", "), "."
|
||||||
|
))
|
||||||
stop("Not all supplied event names are valid")
|
stop("Not all supplied event names are valid")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,15 +129,16 @@ read_redcap_tables <- function(uri,
|
|||||||
# Processing metadata to reflect focused dataset
|
# Processing metadata to reflect focused dataset
|
||||||
m <- focused_metadata(m, names(d))
|
m <- focused_metadata(m, names(d))
|
||||||
|
|
||||||
|
|
||||||
# Splitting
|
# Splitting
|
||||||
out <- REDCap_split(d,
|
if (split_forms != "none") {
|
||||||
|
REDCap_split(d,
|
||||||
m,
|
m,
|
||||||
forms = split_forms,
|
forms = split_forms,
|
||||||
primary_table_name = ""
|
primary_table_name = ""
|
||||||
)
|
) |> sanitize_split()
|
||||||
|
} else {
|
||||||
sanitize_split(out)
|
d
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -234,5 +241,3 @@ apply_factor_labels <- function(data,meta=NULL){
|
|||||||
}
|
}
|
||||||
}) |> dplyr::bind_cols()
|
}) |> dplyr::bind_cols()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user