diff --git a/NEWS.md b/NEWS.md index 1659bf8..03cedb5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,10 @@ * NEW: `as_logical()`: interprets vectors with two levels as logical if values matches supplied list of logical pairs like "TRUE"/"FALSE", "Yes"/"No" or 1/2. Eases interpretation of data from databases with minimal metadata. Works on vectors and for data.frames. Interprets vectors with single value also matching to any of supplied levels (Chooses first match pair if several matches). +* NEW: `easy_redcap()`: new parameter `data_format` to specify data format as c("wide", "list", "redcap", "long"). For now "redcap" and "long" is treated equally. This was added to ease MMRM analyses. In that case, missing baseline values can be carried forward as "last observation carried forward" using the `tidyr::fill()` function specifying variables to fill. Interesting discussion on filling data [here on Stackoverflow](https://stackoverflow.com/a/13810615). `redcap_read_tables()` now has the option "none" for the `split_forms` parameter to allow not splitting the data. + +* FIX: `ds2dd_detailed()`: The `convert_logicals` parameter has been turned off by default and logicals are now interpreted as field type "truefalse". Converting logicals to factors would result in the numeric values being 1 for FALSE and 2 for TRUE, which is opposite of the traditional notation and could lead to serous problems if not handled correctly. This should solve it. + # REDCapCAST 25.1.1 The newly introduced extension of `forcats::fct_drop()` has been corrected to work as intended as a method. diff --git a/man/as_logical.Rd b/man/as_logical.Rd index eb8624f..85e7bc8 100644 --- a/man/as_logical.Rd +++ b/man/as_logical.Rd @@ -52,4 +52,7 @@ ds |> as_logical() |> sapply(class) ds$A |> class() +sample(c("TRUE",NA), 20, TRUE) |> + as_logical() +as_logical(0) } diff --git a/man/ds2dd.Rd b/man/ds2dd.Rd index 83ab6b0..922aa9c 100644 --- a/man/ds2dd.Rd +++ b/man/ds2dd.Rd @@ -49,5 +49,5 @@ Migrated from stRoke ds2dd(). Fits better with the functionality of } \examples{ redcapcast_data$record_id <- seq_len(nrow(redcapcast_data)) -ds2dd(redcapcast_data, include.column.names=TRUE) +ds2dd(redcapcast_data, include.column.names = TRUE) } diff --git a/man/ds2dd_detailed.Rd b/man/ds2dd_detailed.Rd index 113f252..ee81804 100644 --- a/man/ds2dd_detailed.Rd +++ b/man/ds2dd_detailed.Rd @@ -16,7 +16,7 @@ ds2dd_detailed( field.label.attr = "label", field.validation = NULL, metadata = names(REDCapCAST::redcapcast_meta), - convert.logicals = TRUE + convert.logicals = FALSE ) } \arguments{ @@ -91,7 +91,10 @@ iris |> form.name = sample(c("b", "c"), size = 6, replace = TRUE, prob = rep(.5, 2)) ) |> purrr::pluck("meta") -mtcars |> numchar2fct() |> ds2dd_detailed(add.auto.id = TRUE) +mtcars |> + dplyr::mutate(unknown = NA) |> + numchar2fct() |> + ds2dd_detailed(add.auto.id = TRUE) ## Using column name suffix to carry form name data <- iris |> diff --git a/man/easy_redcap.Rd b/man/easy_redcap.Rd index f087d60..d1be2b0 100644 --- a/man/easy_redcap.Rd +++ b/man/easy_redcap.Rd @@ -4,20 +4,30 @@ \alias{easy_redcap} \title{Secure API key storage and data acquisition in one} \usage{ -easy_redcap(project.name, widen.data = TRUE, uri, raw_or_label = "both", ...) +easy_redcap( + project.name, + uri, + raw_or_label = "both", + data_format = c("wide", "list", "redcap", "long"), + widen.data = NULL, + ... +) } \arguments{ \item{project.name}{The name of the current project (for key storage with \link[keyring]{key_set}, using the default keyring)} -\item{widen.data}{argument to widen the exported data} - \item{uri}{REDCap database API uri} \item{raw_or_label}{argument passed on to \link[REDCapCAST]{read_redcap_tables}. Default is "both" to get labelled data.} +\item{data_format}{Choose the data} + +\item{widen.data}{argument to widen the exported data. [DEPRECATED], use +`data_format`instead} + \item{...}{arguments passed on to \link[REDCapCAST]{read_redcap_tables}.} } \value{ diff --git a/man/format_redcap_factor.Rd b/man/format_redcap_factor.Rd index 870bd55..f602b6e 100644 --- a/man/format_redcap_factor.Rd +++ b/man/format_redcap_factor.Rd @@ -19,5 +19,5 @@ Applying \link[REDCapCAST]{as_factor} to the data.frame or variable, will coerce to a factor. } \examples{ -format_redcap_factor(sample(1:3,20,TRUE),"1, First. | 2, second | 3, THIRD") +format_redcap_factor(sample(1:3, 20, TRUE), "1, First. | 2, second | 3, THIRD") } diff --git a/man/read_redcap_tables.Rd b/man/read_redcap_tables.Rd index 75dd3d7..5ba25bc 100644 --- a/man/read_redcap_tables.Rd +++ b/man/read_redcap_tables.Rd @@ -12,7 +12,7 @@ read_redcap_tables( events = NULL, forms = NULL, raw_or_label = c("raw", "label", "both"), - split_forms = "all", + split_forms = c("all", "repeating", "none"), ... ) } @@ -40,7 +40,7 @@ read_redcap_tables( \link[REDCapCAST]{fct_drop} to drop empty levels.} \item{split_forms}{Whether to split "repeating" or "all" forms, default is -all.} +all. Give "none" to export native semi-long REDCap format} \item{...}{passed on to \link[REDCapR]{redcap_read}} }