-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
The importUserRoles function fails with undefined columns selected because it triggers an internal call to exportUserRoles, which attempts to subset the UserRole data frame using a static vector: REDCAP_USER_ROLE_TABLE_ACCESS_VARIABLES.
Based on the REDCap configurations, the API does not return the full set of these variables. The package should dynamically identify which columns exist before attempting to reassign factors or subset the data.
Error Trace
Error in `[.data.frame`(UserRole, REDCAP_USER_ROLE_TABLE_ACCESS_VARIABLES) :
undefined columns selected
Calls: importUserRoles ... exportUserRoles.redcapApiConnection -> lapply -> [ -> [.data.frame
Suggested Fix
Modify the internal subsetting logic to intersect the requested variables with the actual names present in the data frame:
# Current problematic logic likely resembles:
# UserRole[, REDCAP_USER_ROLE_TABLE_ACCESS_VARIABLES]
# Proposed dynamic logic:
existing_vars <- intersect(REDCAP_USER_ROLE_TABLE_ACCESS_VARIABLES, names(UserRole))
UserRole[, existing_vars]
https://github.com/vubiostat/redcapAPI/blob/main/R/exportUserRoles.R#L86
Metadata
Metadata
Assignees
Labels
No labels