diff --git a/R/read_and_process_embrace_plus.R b/R/read_and_process_embrace_plus.R index 374780a..b9db8fb 100644 --- a/R/read_and_process_embrace_plus.R +++ b/R/read_and_process_embrace_plus.R @@ -2,13 +2,31 @@ #' @description Reads the raw ZIP file using `read_embrace_plus`, #' performs analyses with `eda_analysis`. #' @param zipfile zip file with embrace plus data to be read +#' @param folder A folder with the unzipped files. If this is provided, the zipfile is not used. +#' @param type The type of data contained in the zip file. Either "raw" or "aggregated". #' @param tz timezone where data were recorded (default system timezone) #' @return An object with processed data and analyses, object of class 'embrace_plus_analysis'. #' @rdname read_and_process_embrace_plus #' @export -read_and_process_embrace_plus <- function(zipfile, tz = Sys.timezone()) { - data <- read_embrace_plus(zipfile, tz) - data <- rbind_embrace_plus(data) +read_and_process_embrace_plus <- function(zipfile = NULL, folder = NULL, type = "raw", tz = Sys.timezone()) { + + # Check if zipfile or folder is provided + if (is.null(zipfile) && is.null(folder)) { + cli_abort("Either zipfile or folder must be provided") + } + + if (!is.null(zipfile) && !is.null(folder)) { + cli_warning("Only folder will be processed, zipfile will be ignored") + } + + if (!is.null(zipfile)) { + data <- read_embrace_plus(zipfile = zipfile, type = type, tz = tz) + data <- rbind_embrace_plus(data) + } + + if (!is.null(folder)) { + data <- read_embrace_plus(folder = folder, type = type, tz = tz) + } if (is.null(data)) { return(NULL) diff --git a/R/read_embrace_plus.R b/R/read_embrace_plus.R index 1f60335..e1f0b5e 100644 --- a/R/read_embrace_plus.R +++ b/R/read_embrace_plus.R @@ -101,7 +101,7 @@ create_dataframes <- function(data, type, file, vars = c("x", "y", "z"), #' #' @param zipfile A zip file as exported by the instrument. Can be aggregated data, or raw data. #' @param folder A folder with the unzipped files. If this is provided, the zipfile is not used. -#' @param type The type of data contained in the zip file. Either "raw" or "aggregated". +#' @param type The type of data contained in the zip file or folder. Either "raw" or "aggregated". #' @param tz The timezone used by the instrument (defaults to user timezone). #' @examples #' \dontrun{ diff --git a/man/read_and_process_embrace_plus.Rd b/man/read_and_process_embrace_plus.Rd index 2fdd367..52b6159 100644 --- a/man/read_and_process_embrace_plus.Rd +++ b/man/read_and_process_embrace_plus.Rd @@ -4,11 +4,20 @@ \alias{read_and_process_embrace_plus} \title{Read, process and feature extraction of Embrace Plus data} \usage{ -read_and_process_embrace_plus(zipfile, tz = Sys.timezone()) +read_and_process_embrace_plus( + zipfile = NULL, + folder = NULL, + type = "raw", + tz = Sys.timezone() +) } \arguments{ \item{zipfile}{zip file with embrace plus data to be read} +\item{folder}{A folder with the unzipped files. If this is provided, the zipfile is not used.} + +\item{type}{The type of data contained in the zip file. Either "raw" or "aggregated".} + \item{tz}{timezone where data were recorded (default system timezone)} } \value{ diff --git a/man/read_embrace_plus.Rd b/man/read_embrace_plus.Rd index c88599f..66ef607 100644 --- a/man/read_embrace_plus.Rd +++ b/man/read_embrace_plus.Rd @@ -16,7 +16,7 @@ read_embrace_plus( \item{folder}{A folder with the unzipped files. If this is provided, the zipfile is not used.} -\item{type}{The type of data contained in the zip file. Either "raw" or "aggregated".} +\item{type}{The type of data contained in the zip file or folder. Either "raw" or "aggregated".} \item{tz}{The timezone used by the instrument (defaults to user timezone).} }