Learn R Programming

redcapAPI (version 2.8.0)

prepUserImportData: Prepare User Data for Import

Description

Prepares a data frame for import via the API. Allows for data to be passed in either the raw format or the labeled data received from exportUsers.

Usage

prepUserImportData(data, rcon, consolidate = TRUE, user_role = FALSE)

Value

Returns a data.frame with user settings that will be accepted by the API for import.

Arguments

data

data.frame with the structure of redcapAPI:::REDCAP_USER_STRUCTURE. It may also have additional columns for the form and export access of each of the instruments.

rcon

A redcapConnection object.

consolidate

logical(1) If TRUE, the form and data export access values will be read from the expanded columns. Otherwise, the consolidated values (as provided by the API export) are utilized.

user_role

logical(1) If TRUE, the code will treat the data as if it is being prepared for importing User Roles.

See Also

importUsers(),
importUserRoles()

Examples

Run this code
if (FALSE) {
unlockREDCap(connections = c(rcon = "project_alias"), 
             url = "your_redcap_url", 
             keyring = "API_KEYs", 
             envir = globalenv())


# Prep user data
NewData <- data.frame(username = "target_user", 
                      design = 1, 
                      api_export = "Access", 
                      api_import = "No Access", 
                      surveys_enabled = 0)
prepUserImportData(data = NewData, 
                   rcon = rcon)
                   
# Prep user role data
NewData <- data.frame(unique_role_name = "target_user", 
                      design = 1, 
                      api_export = "Access", 
                      api_import = "No Access", 
                      surveys_enabled = 0)
prepUserImportData(data = NewData, 
                   rcon = rcon)
}

Run the code above in your browser using DataLab