mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2024-11-22 13:30:23 +01:00
adding some metadata processing in R package to handle variety of user inputs
This commit is contained in:
parent
a1297903c2
commit
552ac884ff
@ -40,6 +40,7 @@
|
|||||||
#' @export
|
#' @export
|
||||||
REDCap_split <- function(records, metadata) {
|
REDCap_split <- function(records, metadata) {
|
||||||
|
|
||||||
|
# Process user input
|
||||||
records <- JSON2data.frame(records)
|
records <- JSON2data.frame(records)
|
||||||
metadata <- JSON2data.frame(metadata)
|
metadata <- JSON2data.frame(metadata)
|
||||||
|
|
||||||
@ -52,6 +53,24 @@ REDCap_split <- function(records, metadata) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Standardize variable names for metadata
|
||||||
|
names(metadata) <- c(
|
||||||
|
"field_name", "form_name", "section_header", "field_type",
|
||||||
|
"field_label", "select_choices_or_calculations", "field_note",
|
||||||
|
"text_validation_type_or_show_slider_number", "text_validation_min",
|
||||||
|
"text_validation_max", "identifier", "branching_logic", "required_field",
|
||||||
|
"custom_alignment", "question_number", "matrix_group_name", "matrix_ranking",
|
||||||
|
"field_annotation"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Make sure that no metadata columns are factors
|
||||||
|
metadata_factors <- sapply(metadata, inherits, "factor")
|
||||||
|
if(any(metadata_factors)) {
|
||||||
|
|
||||||
|
metadata[metadata_factors] <- lapply(metadata[metadata_factors], as.character)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# Find the fields and associated form
|
# Find the fields and associated form
|
||||||
fields <- metadata[
|
fields <- metadata[
|
||||||
!metadata$field_type %in% c("descriptive", "checkbox"),
|
!metadata$field_type %in% c("descriptive", "checkbox"),
|
||||||
|
Loading…
Reference in New Issue
Block a user