Learn R Programming

redcapAPI (version 2.7.4)

exportReportsTyped: Export a Report from a REDCap Project

Description

Export a Report from a REDCap Project

Usage

exportReportsTyped(rcon, report_id, ...)

# S3 method for redcapApiConnection exportReportsTyped( rcon, report_id, drop_fields = NULL, na = list(), validation = list(), cast = list(), assignment = list(label = stripHTMLandUnicode, units = unitsFieldAnnotation), ..., config = list(), api_param = list(), csv_delimiter = "," )

Arguments

rcon

A redcapConnection object

report_id

integerish(1) The ID number of the report to be exported.

...

Argument to pass to other methods.

drop_fields

character. A vector of field names to remove from the export. Ignore if length = 0.

na

A named list of user specified functions to determine if the data is NA. This is useful when data is loaded that has coding for NA, e.g. -5 is NA. Keys must correspond to a truncated REDCap field type, i.e. date_, datetime_, datetime_seconds_, time_mm_ss, time_hh_mm_ss, time, float, number, calc, int, integer, select, radio, dropdown, yesno, truefalse, checkbox, form_complete, sql. The function will be provided the variables (x, field_name, coding). The function must return a vector of logicals matching the input. It defaults to isNAorBlank for all entries.

validation

A named list of user specified validation functions. The same named keys are supported as the na argument. The function will be provided the variables (x, field_name, coding). The function must return a vector of logical matching the input length. Helper functions to construct these are valRx and valChoice. Only fields that are not identified as NA will be passed to validation functions.

cast

A named list of user specified class casting functions. The same named keys are supported as the na argument. The function will be provided the variables (x, field_name, coding). The function must return a vector of logical matching the input length. See fieldValidationAndCasting

assignment

A named list of functions. These functions are provided, field_name, label, description and field_type and return a list of attributes to assign to the column. Defaults to creating a label attribute from the stripped HTML and UNICODE raw label and scanning for units="UNITS" in description to use as a units attribute.

config

named list. Additional configuration parameters to pass to httr::POST, These are appended to any parameters in rcon$config

api_param

named list. Additional API parameters to pass into the body of the API call. This provides users to execute calls with options that may not otherwise be supported by redcapAPI.

csv_delimiter

character. One of c(",", "\t", ";", "|", "^"). Designates the delimiter for the CSV file received from the API.

Details

This method allows you to export the data set of a report created on a project's 'Data Exports, Reports, and Stats' page.

Note about export rights: Please be aware that Data Export user rights will be applied to this API request. For example, if you have 'No Access' data export rights in the project, then the API report export will fail and return an error. And if you have 'De-Identified' or 'Remove All Identifier Fields' data export rights, then some data fields *might* be removed and filtered out of the data set returned from the API. To make sure that no data is unnecessarily filtered out of your API request, you should have 'Full Data Set' export rights in the project.