Quick links:
- CRAN Archive of older versions
- Current & previous GitHub Issues
- Documentation for current GitHub version
These features are not yet on CRAN. Install with remotes::install_github("OuhscBbmc/REDCapR")
These changes could possibly break existing code --but it's very unlikely. We feel they will (directly and indirectly) improve the package considerably.
-
redcap_read()
,redcap_read_oneshot()
,redcap_dag_read()
,redcap_log_read()
, andredcap_report()
return a tibble instead of a data.frame. (#415)This should affect client code only if you expect a call like
ds[, 3]
to return a vector instead of a single-column data.frame/tibble. One solution is to upcast the tibble to a data.frame (with something likeas.data.frame()
). We recommend using an approach that works for both data.frames and tibbles, such asds[[3]]
ordplyr::pull(ds, "gender")
.For more information, read the short chapter in R for Data Science.
-
The
*_collapsed
parameters are deprecated. When your want to limit on records/fields/forms/events, pass the vector of characters, not the scalar character separated by commas (which I think everyone does already). In other words usec("demographics", "blood_pressure")
instead of"demographics,blood_pressure"
.Here are the relationships between the four pairs of variables:
records_collapsed <- collapse_vector(records , records_collapsed) fields_collapsed <- collapse_vector(fields , fields_collapsed) forms_collapsed <- collapse_vector(forms , forms_collapsed) events_collapsed <- collapse_vector(events , events_collapsed)
If someone is using the *_collapsed parameter, they can programmatically convert it to a vector like:
field_names <- trimws(unlist(strsplit(field_names_collapsed, ",")))
-
redcap_read()
will automatically include the "plumbing" variables, even if they're not included the list of requested fields & forms. (#442). Specifically:record_id
(or it's customized name) will always be returnedredcap_event_name
will be returned for longitudinal projectsredcap_repeat_instrument
andredcap_repeat_instance
will be returned for projects with repeating instruments
This will help extract forms from longitudinal & repeating projects.
-
redcap_read()
andredcap_read_oneshot()
now return an empty dataset if no records are retrieved (such as no records meet the filter criteria). Currently a 0x0 tibble is returned, but that may change in the future. Until now an error was deliberately thrown. (#452) -
redcap_event_instruments()
now by default returns mappings for all arms. The previous default was to return the mappings for only the first arm. To recreate the previous behavior use a call likeREDCapR::redcap_event_instruments(uri, token_2, arms = "1")
. (Suggested by @januz, #482)
- New
redcap_metadata_coltypes()
function. Inspects the fields types and validation text of each field to generate a suggestedreadr::col_types
object that reflects the project's current data dictionary. The object then can be passed to thecol_types
parameter ofredcap_read()
orredcap_read_oneshot()
. (Suggested and discussed with @pbchase, @nutterb, @skadauke, & others, #405 & #294) - New
redcap_log_read()
function. Exports a project's log. (Thanks @joundso, #383, #320) - New
redcap_project_info_read()
function. Exports a project's information, such as its language and production status. (Suggested by @skadauke, @timothytsai, @pbchase, #236, #410) - New parameter
blank_for_gray_form_status
in the functionsredcap_read()
,redcap_read_oneshot()
, andredcap_read_oneshot_eav()
. (@greg-botwin, #386, #389) - A
httr::handle
value is accepted by functions that contact the server. This will accommodate some institutions with unconventional environments. (Suggested by @brandonpotvin, #429) sanitized_token()
now accepts an alternative regex pattern. (Suggested by @maeon & @michalkouril, #370)redcap_read_eav_oneshot()
is an UNexported function that returns data in an EAV format (#437)redcap_metadata_read()
now correctly subsets the forms (identified & corrected by @ezraporter, #431 & #445)- New
redcap_event_read()
function. Exports metadata associated with a project's longitudinal events (@ezraporter, #457 & #460)
-
Better documentation for the server url (suggested by @sutzig #395)
-
read_read_oneshot()
's parameterguess_max
now allows floating point values to supportreadr::read_csv()
ability to accept a Inf value. (Suggested by @eveyp, #392) -
pkgdown pages run & display the examples, but CRAN still doesn't run them. It's illegal to call external resources/APIs from CRAN computers --mostly because they are occasionally unavailable, so the code breaks. (#419)
-
Renamed some functions to follow a consistent pattern. Old names will be soft-deprecated for a while before being removed. (#416)
redcap_download_file_oneshot()
toredcap_file_download_opneshot()
redcap_file_upload_oneshot()
toredcap_file_upload_opneshot()
redcap_download_instrument()
toredcap_instrument_download()
-
redcap_dag_read()
has newdata_access_group_id
field (introduced maybe in 13.1.0) (#459) -
redcap_users_export()
has newmycap_participants
field (introduced maybe in 13.0.0) (#459) -
Accommodate older versions of REDCap that don't return project-level variable, like
has_repeating_instruments_or_events
,missing_data_codes
,external_modules
,bypass_branching_erase_field_prompt
(@the-mad-statter, #465, #466) -
redcap_meta_coltypes()
correctly determines data type for autonumberrecord_id
fields. It suggests a character if the project has DAGs, and an integer if not. (@pwildenhain, #472) -
redcap_log_read()
now returns a new column reflecting the affected record id value (ref #478) -
redcap_read()
andredcap_read_oneshot()
now remove "pseudofields" (e.g.,redcap_event_name
,redcap_repeat_instrument
, &redcap_repeat_instance
) from thefields
parameter. Starting with REDCap v13.4.10, an error is thrown by the server. REDCap will return a message if a common pseudofield is requested explicitly by the user. (#477) -
redcap_event_instruments()
now can return mappings for all arms, instead of one arm per call.(Suggested by @januz, #482) -
validate_for_write()
contains a few more checks. (#485) The complete list is now:validate_data_frame_inherits()
validate_field_names()
validate_record_id_name()
validate_uniqueness()
validate_repeat_instance()
validate_no_logical()
-
redcap_read()
checks theevent
parameter and throws an error if a value is not recognized, or the project is not longitudinal (#493) -
The regex in
regex_named_captures()
is forgiving if there's an unnecessary leading space (@BlairCooper, #495, #501)
- New
redcap_delete()
function. It deletes a vector of records. (Thanks @joundso, #372, #373) - New
redcap_arm_export()
function. It retrieves a list of REDCap project arms. (#375) redcap_read()
andredcap_read_oneshot()
accept a newlocale
parameter that specifies date, time, and number formats, like using a comma as the decimal separator. It is areadr::locale
object. (#377, suggested by @joundso)- New
redcap_instruments()
function exports a list of the data collection instruments for a project. (#381, @vcastro) - New
redcap_event_instruments()
function exports the instrument-event mappings for a project (i.e., how the data collection instruments are designated for certain events in a longitudinal project). (#381, @vcastro) - New
redcap_dag_read()
function returns the Data Access Groups for a project (#382, @joundso) - New detection when REDCap has trouble with a large request and drops records. (#400 w/ @TimMonahan)
sanitize_token()
now allows lowercase characters --in addition to uppercase characters & digits. (#347, @jmbarbone)redcap_metadata_read()
now uses json (instead of csv) to transfer the dictionary between server & client. This accommodates super-wide dictionaries with 35k+ variables. The user shouldn't notice a difference, and still will receive a data.frame. (#335, @januz & @datalorax)- Include a few more
testthat::skip_on_cran()
calls to comply with CRAN's "fail gracefully" policy. Similarly, skip remaining examples that depend on external resources. (#352) retrieve_credential_local()
can now userusername
to identify the desired credential row (#364)redcap_read()
andredcap_read_oneshot()
gain thehttp_response_encoding
parameter that's passed tohttr::content()
. The default value remains "UTF-8". (#354, @lrasmus)- Accommodate single-character REDCap variable names (#367 & #368, @daynefiler)
- Modify
redcap_users_export()
(which calls REDCap's user export). The API dropped thedata_export
variable and added theforms_export
variable. (#396) - For
redcap_read_oneshot_eav()
: if the project isn't longitudinal, a dummy value forevent_id
is used internally (#396) - For the testing server & projects, the http errors are a little different, so the testing code was adjusted (#396)
- Set
httr::user_agent
, following the advice of httr's vignette (#397)
- Added two more dictionaries that are super wide -5k & 35k variables (#335 & #360, @januz & @datalorax)
- Read, modify, & read projects with DAGs (#353, daniela.wolkersdorfer, #353)
The package has been stable for years and should be reflected in the major version number.
- When writing records to the server, the functions
redcap_write()
andredcap_write_oneshot()
have a new parameter that converts R'slogical
/boolean columns to integers. This meshes well with T/F and Y/N items that are coded as 1/0 underneath. The default will be FALSE (ie, the integers are not converted by default), so it doesn't break existing code. (#305) - When writing records to the server, the functions
redcap_write()
andredcap_write_oneshot()
can toggle the ability to overwrite with blank/NA cells (suggested by @auricap, #315) - The functions
redcap_read_oneshot()
,redcap_read()
, &redcap_read_oneshot_eav()
now support the parametersdatetime_range_begin
anddatetime_range_end
. The are passed to the REDCap parametersdateRangeBegin
anddateRangeEnd
, which restricts records returned, based on their last modified date in the server. (Thanks @pbchase, #321 & #323.) - Better documentation about the
export_survey_fields
parameter in the functionsredcap_read()
&redcap_read_oneshot()
. (Thanks @isaactpetersen, #333) - New function
redcap_report()
export records that populate a REDCap report. (#326.) - New vignette Typical REDCap Workflow for a Data Analyst developed to support a workshop for the 2021 R/Medicine Conference (#332, with @higgi13425, @kamclean, & Amanda Miller)
- New function
create_credential_local()
starts a well-formed csv file that can contain tokens. (#340, after conversations with @higgi13425 & @kamclean.)
- update for newer version of testthat -v3.0.0 (#312)
- update for newer version of readr 2.0.0 (#343)
- update for newer version of readr 1.4.0 (#313)
- update for newer version of REDCap on test server (#310)
- save expected datasets as files -instead of included in the actual test code (#308)
- Accepts more than one
config_option
element. (Proposed by @BastienRance, #307) - Fixed calculation of
success
value returned byredcap_read()
andredcap_write()
when the parametercontinue_on_error
is true. (Bug found by @llrs, #317)
-
kernel_api()
defaults to "text/csv" and UTF-8 encoding. Formerly, the function would decide on the content-type and encoding. More details are below in the 'Stability Features' subsection. -
constant()
no longer acceptssimplify
as an options. An integer vector is always returned. (#280)
-
It's now possible to specify the exact
col_types
(areadr::cols
object) that is passed toreadr::read_csv()
insideredcap_read_oneshot()
. (#258) -
reader::type_convert()
is used after all the batches are stacked on top of each other. This way, batches cannot have incompatible data types as they're combined. (#257; thanks @isaactpetersen #245) Consequently, theguess_max
parameter inredcap_read()
no longer serves a purpose, and has been soft-deprecated. (#267) -
redcap_metadata_write()
writes to the project's metadata. (#274, @felixetorres) -
redcap_survey_link_export_oneshot()
retrieves the URL to a specific record's survey (e.g., "https://bbmc.ouhsc.edu/redcap/surveys/?s=8KuzSLMHf6") (#293) -
convert_logical_to_integer
is a new parameter forredcap_write()
andredcap_write_oneshot()
. IfTRUE
, all [base::logical] columns inds
are cast to an integer before uploading to REDCap. Boolean values are typically represented as 0/1 in REDCap radio buttons. Defaults toFALSE
to maintain backwards compatibility. (#305)
-
httr::content()
(which is insidekernel_api()
) now processes the returned value as "text/csv", by default. This should prevent strange characters from tricking the process as the internal variableraw_text
is being formed. See the [httr::content()](https://httr.r-lib.org/reference/content.html) documentation for a list of possible values for the
content_type` parameter. (Thanks to great debugging by @vortexing #269, @sybandrew #272, & @begavett, #290) -
Similarly,
kernel_api()
now has anencoding
parameter, which defaults to "UTF-8". (#270)
- check for bad field names passed to the read records functions (#288)
-
'checkmate' package is now imported, not suggested (Thanks @dtenenba, #255).
-
Allow more than one
httr::config()
parameter to be passed (Thanks @BastienRance, #307).
- export survey time-stamps optionally (Issue #159)
redcap_next_free_record_name()
: API call for 'Generate Next Record Name', which returns the next available record ID (Issue #237)redcap_read()
andredcap_read_oneshot()
allow the user to specify if all variables should be returned with thecharacter
data type. The default is to allowreadr::read_csv()
to guess the data type. (#194)redcap_read_oneshot()
allows use to specify how many rows should be considered whenreadr::read_csv()
guesses the data type. (#194)redcap_read()
,redcap_read_oneshot()
, andredcap_read_oneshot_eav()
always return Linux-style line endings (ie\n
) instead of Windows style line endings (ie,\r\n
) on all OSes. (#198)read_metadata()
always returnscharacter
vectors for all variables. With readr 1.2.0, some column were returned differently than before. (#193)- 'raw_or_label_headers' now supported (Thanks Hatem Hosny - hatemhosny, #183 & #203)
- 'export_checkbox_labels' now supported (#186)
redcap_users_export()
now included (#163)- 'forms' now supported for
redcap_read()
,redcap_read_oneshot()
, &redcap_read_oneshot_eav()
(#206). It was already implemented forredcap_metadata_read()
. - If no records are affected, a zero-length character vector is returned (instead of sometimes a zero-length numeric vector) (#212)
- New function (called
constants()
) easily exposes REDCap-specific constants. (#217) id_position
allows user to specify if the record_id isn't in the first position (#207). However, we recommend that all REDCap projects keep this important variable first in the data dictionary.- Link to new secure Zenodo DOI resolver (@katrinleinweber #191)
- parameters in
redcap_read()
andredcap_read_oneshot()
are more consistent with the order in raw REDCap API. (#204) - When the
verbose
parameter is NULL, then the value from getOption("verbose") is used. (#215) guess_max
parameter provided inredcap_read()
(no longer justredcap_read_oneshot()
). Suggested by @isaactpetersen in #245.- Documentation website constructed with pkgdown (#224).
redcap_variables()
now throws an error when passed a bad URI (commit e542155639bbb7).
- All interaction with the REDCap server goes through the new
kernal_api()
function, which uses the 'httr' and 'curl' packages underneath. Until now, each function called those packages directly. (#213) - When converting REDCap's CSV to R's data.frame,
readr::read_csv()
is used instead ofutils::read.csv()
(Issue #127). - updated to readr 1.2.0 (#200). This changed how some data variables were assigned a data types.
- uses
odbc
package to retrieve credentials from the token server. Remove RODBC and RODBCext (#188). Thanks to @krlmlr for error checking advice in https://stackoverflow.com/a/50419403/1082435. data.table::rbindlist()
replaced bydplyr::bind_rows()
- the checkmate package inspects most function parameters now (instead of
testit::assert()
andbase:stop()
) (#190 & #208). collapse_vector()
is refactored and tested (#209)- remove dependency on
pkgload
package (#218) - Update Markdown syntax to new formatting problems (#253)
retrieve_token_mssql()
, becauseretrieve_credential_mssql()
is more general and more useful.
- Enumerate the exported variables. with
redcap_variables()
. - Experimental EAV export in
redcap_read_oneshot_eav()
, which can be accessed with a triple colon (ie,REDCapR::redcap_read_oneshot_eav()
).
- Adapted to new 2.4 version of curl (see #154)
- Support for filtering logic in
redcap_read()
andredcap_read_oneshot()
(PR #126) - New functions
retrieve_credential_mssql()
andretrieve_credential_local()
. These transition from storing & retrieving just the token (ie,retrieve_token_mssql()
) to storing & retrieving more information.retrieve_credential_local()
facilitates a standard way of storing tokens locally, which should make it easier to follow practices of keeping it off the repository. - Using parameterized queries with the RODBCext package. (Thanks @nutterb in issues #115 & #116.)
- Remove line breaks from token (Thanks @haozhu233 in issues #103 & #104)
- When combining batches into a single data.frame,
data.table::rbindlist()
is used. This should prevent errors with the first batch's data type (for a column) isn't compatible with a later batch. For instance, this occurs when the first batch has only integers forrecord_id
, but a subsequent batch has values likeaa-test-aa
. The variable for the combined dataset should be a character. (Issue #128 & https://stackoverflow.com/questions/39377370/bind-rows-of-different-data-types; Thanks @arunsrinivasan) - Uses the
dplyr
package instead ofplyr
. This shouldn't affect callers, because immediately before returning the data,REDCapR::redcap_read()
coerces thetibble::tibble
(which was formerly calleddplyr::tbl_df
) back to a vanilladata.frame
withas.data.frame()
. - A few more instances of validating input parameters to read functions. (Issue #8).
- The
retrieve-token()
tests now account for the (OS X) builds where the RODBC package isn't available.
- Adapted for version 1.0.0 of httr (which is now based on the
curl
package, instead ofRCurl
).
- Uses
requireNamespace()
instead ofrequire()
. - By default, uses the SSL cert files used by httr, which by default, uses those packaged with R.
- Added warning if it appears
readcap_read()
is being used without 'Full Data Set' export privileges. The problem involves the record IDs are hashed. - Reconnected code that reads only the
id_position
in the first stage of batching. The metadata needed to be read before that, after the updates for REDCap Version 6.0.x. retrieve_token_mssql()
uses regexes to validate parameters
- Updated for Version 6.0.x of REDCap (which introduced a lot of improvements to API behavior).
- The
config_options
in the httr package are exposed to the REDCapR user. See issues #55 & #58; thanks to @rparrish and @nutterb for their contributions (OuhscBbmc#55 & OuhscBbmc#58).
redcap_metadata_read()
are tested and public.
- Test suite now uses
testthat::skip_on_cran()
before any call involving OUHSC's REDCap server. - Vignette example of subsetting, conditioned on a second variable's value.
redcap_write()
andredcap_write_oneshot()
are now tested and public.redcap_write()
andredcap_write_oneshot()
are now tested and public.redcap_download_file_oneshot()
function contributed by John Aponte (@johnaponte; Pull request #35)redcap_upload_file_oneshot()
function contributed by @johnaponte (Pull request #34)- Users can specify if an operation should continue after an error occurs on a batch read or write. Regardless of their choice, more debugging output is written to the console if
verbose==TRUE
. Follows advice of @johnaponte, Benjamin Nutter (@nutterb), and Rollie Parrish (@rparrish). Closes #43.
- The
records_collapsed
default empty value is now an empty string (i.e.,""
) instead ofNULL
. This applies whenrecords_collapsed
is either a parameter, or a returned value.
- By default, the SSL certs come from the httr package. However, REDCapR will continue to maintain a copy in case httr's version on CRAN gets out of date.
- The tests are split into two collections: one that's run by the CRAN checks, and the other run manually. Thanks, Gabor Csardi. Any test with a dependency outside the package code (especially the REDCap test projects) is run manually so changes to the test databases won't affect the success of building the previous version on CRAN.
- Corrected typo in
redcap_download_file_oneshot()
documentation, thanks to Andrew Peters (@ARPeters #45).
- Relies on the
httr
package, which provides benefits like the status code message can be captured (eg, 200-OK, 403-Forbidden, 404-NotFound). See https://cran.r-project.org/package=httr.
- Renamed the former
status_message
tooutcome_message
. This is because the message associated with http code returned is conventionally called the 'status messages' (eg, OK, Forbidden, Not Found). - If an operation is successful, the
raw_text
value (which was formerly calledraw_csv
) is returned as an empty string to save RAM. It's not really necessary with httr's status message exposed.
- Correct batch reads with longitudinal schema #27
- Added
redcap_column_sanitize()
function to address non-ASCII characters - Added
redcap_write()
(as an internal function). - The
redcap_project()
object reduces repeatedly passing parameters like the server URL, the user token, and the SSL cert location.
- New Mozilla SSL Certification Bundles released on cURL (released 2013-12-05)
- Renamed
redcap_read_batch()
toredcap_read()
. These changes reflect our suggestion that reads should typically be batched. - Renamed
redcap_read()
toredcap_read_oneshot()
- Renamed
redcap_write()
toredcap_write_oneshot()
(which is an internal function). - Small renames to parameters
- Introduces
redcap_read()
andredcap_read_batch()
with documentation - SSL verify peer by default, using cert file included in package
- Initial submission to GitHub
redcap_read()
takes parameter forraw_or_label
(Thanks Rollie Parrish #3)redcap_read()
takes parameter forexport_data_access_groups
thanks to Rollie Parrish (@rparrish #4)
GitHub Commits and Releases
- For a detailed change log, please see https://github.com/OuhscBbmc/REDCapR/commits/main.
- For a list of the major releases, please see https://github.com/OuhscBbmc/REDCapR/releases.