View source: R/redcap-delete.R
redcap_delete | R Documentation |
Delete existing records by their ID from REDCap.
redcap_delete(
redcap_uri,
token,
records_to_delete,
arm_of_records_to_delete = NULL,
verbose = TRUE,
config_options = NULL,
handle_httr = NULL
)
redcap_uri |
The uri/url of the REDCap server typically formatted as "https://server.org/apps/redcap/api/". Required. |
token |
The user-specific string that serves as the password for a project. Required. |
records_to_delete |
A character vector of the project's |
arm_of_records_to_delete |
A single integer reflecting the arm containing the records to be deleted. Leave it as NULL if the project has no arms and is not longitudinal. Required if the REDCap project has arms. See Details below. |
verbose |
A boolean value indicating if |
config_options |
A list of options passed to |
handle_httr |
The value passed to the |
REDCap requires that at least one record_id
value be passed to
the delete call.
When the project has arms, REDCapR has stricter requirements than REDCap.
If the REDCap project has arms, a value must be passed to
arm_of_records_to_delete
. This is a different behavior than calling
the server through cURL –which if no arm number is specified,
then all arms are cleared of the specified record_id
s.
Note that all longitudinal projects technically have arms, even if
only one arm is defined. Therefore a value of arm_number
must be
specified for all longitudinal projects.
Currently, a list is returned with the following elements:
success
: A boolean value indicating if the operation was apparently
successful.
status_code
: The
http status code
of the operation.
outcome_message
: A human readable string indicating the operation's
outcome.
records_affected_count
: The number of records inserted or updated.
elapsed_seconds
: The duration of the function.
raw_text
: If an operation is NOT successful, the text returned by
REDCap. If an operation is successful, the raw_text
is returned as an
empty string to save RAM.
Jonathan Mang, Will Beasley
The official documentation can be found on the 'API Help Page' and 'API Examples' pages on the REDCap wiki (i.e., https://community.projectredcap.org/articles/456/api-documentation.html and https://community.projectredcap.org/articles/462/api-examples.html). If you do not have an account for the wiki, please ask your campus REDCap administrator to send you the static material.
if (FALSE) {
records_to_delete <- c(102, 103, 105, 120)
# Deleting from a non-longitudinal project with no defined arms:
REDCapR::redcap_delete(
redcap_uri = uri,
token = token,
records_to_delete = records_to_delete,
)
# Deleting from a project that has arms or is longitudinal:
arm_number <- 2L # Not the arm name
REDCapR::redcap_delete(
redcap_uri = uri,
token = token,
records_to_delete = records_to_delete,
arm_of_records_to_delete = arm_number
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.