Skip to content

Commit

Permalink
allow nonnumeric ids
Browse files Browse the repository at this point in the history
ref #145, #420
  • Loading branch information
wibeasley committed Oct 1, 2022
1 parent 01531fc commit 31d1d86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion R/redcap-read-oneshot-eav.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ redcap_read_oneshot_eav <- function(
dplyr::mutate(
is_checkbox = (.data$field_type == "checkbox"),
ids = dplyr::if_else(.data$is_checkbox, .data$select_choices_or_calculations, "1"),
ids = gsub("(\\d+),.+?(\\||$)", "\\1", .data$ids),
ids = gsub("(\\w+),.+?(\\||$)", "\\1", .data$ids),
ids = strsplit(.data$ids, " ")
) %>%
dplyr::select(-.data$select_choices_or_calculations, -.data$field_type) %>%
Expand Down
10 changes: 7 additions & 3 deletions playgrounds/eav-playground.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ requireNamespace("testit")

# ---- declare-globals ---------------------------------------------------------
redcap_uri <- "https://bbmc.ouhsc.edu/redcap/api/"
token <- "D70F9ACD1EDD6F151C6EA78683944E98" #This is for a PHI-free demo project
token <- "9A81268476645C4E5F03428B8AC3AA7B" # PHI-free demo: simple static
token <- "5007DC786DBE39CE77ED8DD0C68069A6" # PHI-free demo: Checkboxes 1
# token <- "CCB7E11837D41126D67C744F97389E04" # PHI-free demo: super-wide --3,000 columns
# token <- "5C1526186C4D04AE0A0630743E69B53C" # PHI-free demo: super-wide #3--35,000 columns
# token <- "56F43A10D01D6578A46393394D76D88F" # PHI-free demo: Repeating Instruments --Sparse

raw_or_label <- "raw"
export_data_access_groups_string <- "false"
Expand Down Expand Up @@ -45,7 +49,7 @@ raw_text <- httr::content(r, "text")

ds_eav <- readr::read_csv(raw_text, show_col_types = FALSE)
})

# stop()
# ds_eav$field_name


Expand Down Expand Up @@ -76,7 +80,7 @@ distinct_checkboxes <-
dplyr::filter(.data$is_checkbox) %>%
dplyr::pull(.data$field_name)

ds_possible_checkbox_rows <-
ds_possible_checkbox_rows <-
tidyr::crossing(
field_name = distinct_checkboxes,
record = unique(ds_eav$record),
Expand Down

0 comments on commit 31d1d86

Please sign in to comment.