CHOP-CGTInformatics / REDCapTidieR

Makes it easy to read REDCap Projects into R
https://chop-cgtinformatics.github.io/REDCapTidieR/
Other
33 stars 8 forks source link

[BUG] read_redcap Checkbox Example Not Working #105

Closed rsh52 closed 1 year ago

rsh52 commented 1 year ago

Expected Behavior

The following is resultant of meeting with Will on 2022-12-08

Checkboxes should be exported from REDCap appropriately.

Current Behavior

When testing with Will's example checkbox database, checkbox exports did not come out as expected:

https://github.com/OuhscBbmc/REDCapR/blob/main/inst/misc/example.credentials#L36

Screenshots In the image below, only two checkbox variables exist (checkbox_one___1, checkbox_two___a), though there are multiple options for each of these in the REDCap client side UI.

image

Checklist

Before submitting this issue, please check and verify below that the submission meets the below criteria:

skadauke commented 1 year ago

I think the culprit is line 104 in utils.R, in parse_labels():

    strsplit(" \\| ") # Split by "|"

We're splitting by pipes surrounded by blanks. Here is what the select_choices_or_calculations column are for the field in question:

1, one|2, two|3, three|4, four
a, A|b, B|c, C|d, D|e, E

No spaces! I think the fix is to split by pipe (without spaces) and then remove any padding whitespaces.