Closed rsh52 closed 2 weeks ago
I'm not opposed to this solution but an alternative would be to make event_name
a factor
that has all the levels in the right order. This is consistent with how we handle categorical variables in the data tibbles so I prefer it but not strongly.
I'm not opposed to this solution but an alternative would be to make
event_name
afactor
that has all the levels in the right order. This is consistent with how we handle categorical variables in the data tibbles so I prefer it but not strongly.
Sure that works too, probably preferable! Still would need to come from determination with redcap_event_read()
and then implementing the factor change back in after the link_arms()
function output here.
Feature Request Description
After #209, we now have expanded information about REDCap events under the
redcap_events
supertibble for longitudinal projects. Currently, this includes the columnsredcap_event
,event_name
,redcap_arm
,arm_name
, andrepeat_type
. Example:However, each of these columns is a character type. For downstream processing, there is no way to determine the event level order from the supertibble.
Proposed Solution
Instead of having a separate object summary with all events, perhaps we could include a column above for "
event_order
" or similar that assigns a numeric value to the row equal to the event level order.This can be calculated internally at
link_arms()
when we grab all the events withREDCapR::redcap_event_read()
, the output of it is already in the correct order.https://github.com/CHOP-CGTInformatics/REDCapTidieR/blob/771a56a35bb065e8354bd4113cb16768011574ca/R/utils.R#L153-L162
Additional Context
This came up while working on
REDCapExploreR
in an attempt to shift all reliance of therecord_status_dashboard()
function over to the supertibble, and nix any API requirements for tokens.We are able to assume the factor level order of the form names because they should be represented by the order they appear in the
redcap_form_name
column, identically to what comes out of REDCap itself.Checklist