View source: R/docsEventMethods.R
eventsMethods | R Documentation |
These methods enable the user to export event settings, import new events, update settings for existing events, or delete events.
exportEvents(rcon, ...)
importEvents(rcon, data, override = FALSE, ...)
deleteEvents(rcon, events = NULL, ...)
## S3 method for class 'redcapApiConnection'
exportEvents(
rcon,
arms = NULL,
...,
error_handling = getOption("redcap_error_handling"),
config = list(),
api_param = list()
)
## S3 method for class 'redcapApiConnection'
importEvents(
rcon,
data,
override = FALSE,
...,
error_handling = getOption("redcap_error_handling"),
config = list(),
api_param = list()
)
## S3 method for class 'redcapApiConnection'
deleteEvents(
rcon,
events = NULL,
...,
error_handling = getOption("redcap_error_handling"),
config = list(),
api_param = list()
)
rcon |
A |
arms |
|
events |
|
data |
|
override |
|
... |
Arguments to pass to other methods |
error_handling |
|
config |
A named |
api_param |
A named |
Exporting events is not supported for classical REDCap projects. If the user attempts to export arms for a classical project, a data frame will be returned with zero rows.
Additionally, in order for events to be exported, the project must be
longitudinal, have at least one arm, and at least one event defined.
When these conditions are not satifisfied, exportEvents
will return a data frame with zero rows.
To import new events, the user must provide data with the
unique_event_name
set to NA
(REDCap assigns the unique
event name automatically from the user provided event_name
).
To modify existing events, the user must provide the unique_event_name
.
The other fields in the data provided will overwrite the current values
for the matching event.
Deleting events–whether by deleteEvents
or importEvents
with
override = TRUE
–is a destructive act that also deletes
arms and records associated with the event. This is irreversible
data loss. REDCap will only permit these actions to occur in projects
in Development status.
exportEvents
returns a data frame with the columns:
event_name | The user provided name for the event. |
arm_num | The arm number the event is associated with. |
unique_event_name | The REDCap generated event name. |
custom_event_label | An optional user provided label that may be used in place of the event name. |
event_id | REDCap's internal event identifier. |
days_offset | The number of days since time zero (start of the study or project period) an event is scheduled to occur. This field is only provided when the scheduling module is enabled. |
offset_min | The number of days before the days_offset during which the event may occur. This field is only provided when the scheduling module is enabled. |
offset_max | The number of days before the days_offset during which the event may occur. This field is only provided when the scheduling module is enabled. |
importEvents
invisibly returns the number of events added or modified.
deleteEvents
invisibly returns the number of events deleted.
exportEvents()
: Export events from a REDCap project.
importEvents()
: Add events to a project or modify existing events.
deleteEvents()
: Delete events from a project.
exportMappings()
,
importMappings()
## Not run:
unlockREDCap(connections = c(rcon = "project_alias"),
url = "your_redcap_url",
keyring = "API_KEYs",
envir = globalenv())
# Export all events
exportEvents(rcon)
# Export events for a subset of arms
exportEvents(rcon,
arms = c(1, 3))
# Import new events
NewEvents <- data.frame(event_name = c("Event 1",
"Event 2"),
arm_num = c(1, 1))
importEvents(rcon,
data = NewEvents)
# Modify existing events
UpdateEvents <- data.frame(event_name = "Event 2 New Name",
arm_num = 1,
unique_event_name = "event_2_arm_1",
custom_event_label = "The second visit")
importEvents(rcon,
data = UpdateEvents)
# Replace all events with a new set
NewEvents <- data.frame(event_name = c("Event 1",
"Event 2",
"Event 1"),
arm_num = c(1, 1, 2))
importEvents(rcon,
data = NewEvents,
override = TRUE)
# Delete events
deleteEvents(rcon,
events = c("event_1_arm_1", "event_1_arm_2"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.