From 9d0f92d15448e204f7d6cd7a81528a262e908028 Mon Sep 17 00:00:00 2001 From: Andreas Gammelgaard Damsbo Date: Wed, 28 Jan 2026 22:27:58 +0100 Subject: [PATCH] feat: default generic filename and ensure correct suffix --- R/export_redcap_instrument.R | 13 ++++++++++--- man/export_redcap_instrument.Rd | 7 ++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/R/export_redcap_instrument.R b/R/export_redcap_instrument.R index c71abf1..4da5f33 100644 --- a/R/export_redcap_instrument.R +++ b/R/export_redcap_instrument.R @@ -36,10 +36,16 @@ #' # ) |> #' # purrr::pluck("meta") |> #' # export_redcap_instrument(file=here::here(paste0("instrument",Sys.Date(),".zip"))) -export_redcap_instrument <- function(data, - file, +export_redcap_instrument <- function( + data, + file=here::here(paste0("instrument_",Sys.Date(),".zip")), force = FALSE, record.id = "record_id") { + # Ensure file name ends with .zip + if (!isTRUE(endsWith(file,".zip"))){ + file <- paste0(file,".zip") + } + # Ensure form name is the same if (force) { data$form_name <- data$form_name[1] @@ -67,9 +73,10 @@ export_redcap_instrument <- function(data, } -#' DEPRICATED Create zips file with necessary content based on data set +#' DEPRECATED Create zips file with necessary content based on data set #' #' @description +#' Use export_redcap_instrument() #' Metadata can be added by editing the data dictionary of a project in the #' initial design phase. If you want to later add new instruments, this #' function can be used to create (an) instrument(s) to add to a project in diff --git a/man/export_redcap_instrument.Rd b/man/export_redcap_instrument.Rd index 3af78d8..7c8e76b 100644 --- a/man/export_redcap_instrument.Rd +++ b/man/export_redcap_instrument.Rd @@ -4,7 +4,12 @@ \alias{export_redcap_instrument} \title{Creates zip-file with necessary content to manually add instrument to database} \usage{ -export_redcap_instrument(data, file, force = FALSE, record.id = "record_id") +export_redcap_instrument( + data, + file = here::here(paste0("instrument_", Sys.Date(), ".zip")), + force = FALSE, + record.id = "record_id" +) } \arguments{ \item{data}{metadata for the relevant instrument.