mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2025-04-03 14:42:33 +02:00
Compare commits
4 Commits
7d82eeebd4
...
3eea26223b
Author | SHA1 | Date | |
---|---|---|---|
3eea26223b | |||
0e900a2776 | |||
7bbc147304 | |||
8d20901636 |
21
DESCRIPTION
21
DESCRIPTION
@ -1,6 +1,6 @@
|
|||||||
Package: REDCapCAST
|
Package: REDCapCAST
|
||||||
Title: REDCap Metadata Casting and Castellated Data Handling
|
Title: REDCap Metadata Casting and Castellated Data Handling
|
||||||
Version: 24.12.1
|
Version: 25.1.1
|
||||||
Authors@R: c(
|
Authors@R: c(
|
||||||
person("Andreas Gammelgaard", "Damsbo", email = "agdamsbo@clin.au.dk",
|
person("Andreas Gammelgaard", "Damsbo", email = "agdamsbo@clin.au.dk",
|
||||||
role = c("aut", "cre"),comment = c(ORCID = "0000-0002-7559-1154")),
|
role = c("aut", "cre"),comment = c(ORCID = "0000-0002-7559-1154")),
|
||||||
@ -21,7 +21,7 @@ Description: Casting metadata for REDCap database creation and handling of
|
|||||||
4) procedures for data integration and interoperability with external
|
4) procedures for data integration and interoperability with external
|
||||||
sources (Harris et al (2009) <doi:10.1016/j.jbi.2008.08.010>;
|
sources (Harris et al (2009) <doi:10.1016/j.jbi.2008.08.010>;
|
||||||
Harris et al (2019) <doi:10.1016/j.jbi.2019.103208>).
|
Harris et al (2019) <doi:10.1016/j.jbi.2019.103208>).
|
||||||
Depends: R (>= 3.4.0)
|
Depends: R (>= 4.1.0)
|
||||||
Suggests:
|
Suggests:
|
||||||
httr,
|
httr,
|
||||||
jsonlite,
|
jsonlite,
|
||||||
@ -34,7 +34,8 @@ Suggests:
|
|||||||
roxygen2,
|
roxygen2,
|
||||||
spelling,
|
spelling,
|
||||||
rhub,
|
rhub,
|
||||||
rsconnect
|
rsconnect,
|
||||||
|
pkgconfig
|
||||||
License: GPL (>= 3)
|
License: GPL (>= 3)
|
||||||
Encoding: UTF-8
|
Encoding: UTF-8
|
||||||
LazyData: true
|
LazyData: true
|
||||||
@ -50,19 +51,21 @@ Imports:
|
|||||||
purrr,
|
purrr,
|
||||||
readr,
|
readr,
|
||||||
stats,
|
stats,
|
||||||
shiny,
|
|
||||||
haven,
|
|
||||||
zip,
|
zip,
|
||||||
assertthat,
|
assertthat,
|
||||||
openxlsx2,
|
|
||||||
readODS,
|
|
||||||
forcats,
|
forcats,
|
||||||
vctrs,
|
vctrs,
|
||||||
gt,
|
gt,
|
||||||
bslib,
|
bslib,
|
||||||
here,
|
here,
|
||||||
glue,
|
glue,
|
||||||
gtsummary
|
gtsummary,
|
||||||
|
shiny,
|
||||||
|
haven,
|
||||||
|
openxlsx2,
|
||||||
|
readODS
|
||||||
|
Language: en-US
|
||||||
|
VignetteBuilder: knitr
|
||||||
Collate:
|
Collate:
|
||||||
'REDCapCAST-package.R'
|
'REDCapCAST-package.R'
|
||||||
'utils.r'
|
'utils.r'
|
||||||
@ -82,5 +85,3 @@ Collate:
|
|||||||
'redcapcast_data.R'
|
'redcapcast_data.R'
|
||||||
'redcapcast_meta.R'
|
'redcapcast_meta.R'
|
||||||
'shiny_cast.R'
|
'shiny_cast.R'
|
||||||
Language: en-US
|
|
||||||
VignetteBuilder: knitr
|
|
||||||
|
@ -28,6 +28,7 @@ export(clean_redcap_name)
|
|||||||
export(compact_vec)
|
export(compact_vec)
|
||||||
export(create_html_table)
|
export(create_html_table)
|
||||||
export(create_instrument_meta)
|
export(create_instrument_meta)
|
||||||
|
export(cut_string_length)
|
||||||
export(d2w)
|
export(d2w)
|
||||||
export(doc2dd)
|
export(doc2dd)
|
||||||
export(ds2dd)
|
export(ds2dd)
|
||||||
@ -73,11 +74,15 @@ importFrom(REDCapR,redcap_metadata_read)
|
|||||||
importFrom(REDCapR,redcap_read)
|
importFrom(REDCapR,redcap_read)
|
||||||
importFrom(forcats,as_factor)
|
importFrom(forcats,as_factor)
|
||||||
importFrom(forcats,fct_drop)
|
importFrom(forcats,fct_drop)
|
||||||
|
importFrom(haven,read_dta)
|
||||||
importFrom(keyring,key_get)
|
importFrom(keyring,key_get)
|
||||||
importFrom(keyring,key_list)
|
importFrom(keyring,key_list)
|
||||||
importFrom(keyring,key_set)
|
importFrom(keyring,key_set)
|
||||||
importFrom(openxlsx2,read_xlsx)
|
importFrom(openxlsx2,read_xlsx)
|
||||||
importFrom(purrr,reduce)
|
importFrom(purrr,reduce)
|
||||||
|
importFrom(readODS,read_ods)
|
||||||
importFrom(readr,parse_time)
|
importFrom(readr,parse_time)
|
||||||
|
importFrom(readr,read_csv)
|
||||||
|
importFrom(readr,read_rds)
|
||||||
importFrom(tidyr,pivot_wider)
|
importFrom(tidyr,pivot_wider)
|
||||||
importFrom(tidyselect,all_of)
|
importFrom(tidyselect,all_of)
|
||||||
|
14
NEWS.md
14
NEWS.md
@ -1,18 +1,24 @@
|
|||||||
# REDCapCAST 24.12.2
|
# REDCapCAST 25.1.1
|
||||||
|
|
||||||
The newly introduced extension of `forcats::fct_drop()` has been corrected to work as intended as a method.
|
The newly introduced extension of `forcats::fct_drop()` has been corrected to work as intended as a method.
|
||||||
|
|
||||||
|
Conversion of column names to `field_names` are aligning better with REDCap naming.
|
||||||
|
|
||||||
|
Shorten variable names above 100 characters (REDCap criteria; note recommended variable name length is <26)
|
||||||
|
|
||||||
|
Fixed a params conflict in easy_redcap() when specifying raw_or_label.
|
||||||
|
|
||||||
# REDCapCAST 24.12.1
|
# REDCapCAST 24.12.1
|
||||||
|
|
||||||
This release attempts to solve problems hosting the shiny_cast app, while also implementing functions to preserve as much meta data as possible from the REDCap database when exporting data.
|
This release attempts to solve problems hosting the shiny_cast app, while also implementing functions to preserve as much meta data as possible from the REDCap database when exporting data.
|
||||||
|
|
||||||
The hosting on shinyapps.io has given a lot of trouble recently. Modified package structure a little around the `shiny_cast()`, to accommodate an alternative hosting approach with all package functions included in a script instead of requiring the package.
|
The hosting on shinyapps.io has given a lot of trouble recently. Modified package structure a little around the `shiny_cast()`, to accommodate an alternative hosting approach with all package functions included in a script instead of requiring the package.
|
||||||
|
|
||||||
* NEW: A new option to `raw_or_label` in `read_readcap_tables()` has been added: "both". Get raw values with REDCap labels applied as labels. Use `as_factor()` to format factors with original labels and use the `gtsummary` package to easily get beautiful tables with original labels from REDCap. Use `fct_drop()` to drop empty levels.
|
* NEW: A new option to `raw_or_label` in `read_redcap_tables()` has been added: "both". Get raw values with REDCap labels applied as labels. Use `as_factor()` to format factors with original labels and use the `gtsummary` package to easily get beautiful tables with original labels from REDCap. Use `fct_drop()` to drop empty levels.
|
||||||
|
|
||||||
* NEW: fct_drop() has been added with an extension to `forcats::fct_drop()`, that works across data.frames. Use as `fct_drop()`.
|
* NEW: fct_drop() has been added with an extension to `forcats::fct_drop()`, that works across data.frames. Use as `fct_drop()`.
|
||||||
|
|
||||||
* CHANGE: the default data export method of `easy_redcap()` has been changed to use the new labelled data export with `read_readcap_tables()`.
|
* CHANGE: the default data export method of `easy_redcap()` has been changed to use the new labelled data export with `read_redcap_tables()`.
|
||||||
|
|
||||||
# REDCapCAST 24.11.3
|
# REDCapCAST 24.11.3
|
||||||
|
|
||||||
@ -165,7 +171,7 @@ The main goal this package is to keep the option to only export a defined subset
|
|||||||
|
|
||||||
### Functions:
|
### Functions:
|
||||||
|
|
||||||
* `read_redcap_tables()` **NEW**: this function is mainly an implementation of the combined use of `REDCapR::readcap_read()` and `REDCap_split()` to maintain the focused nature of `REDCapR::readcap_read()`, to only download the specified data. Also implements tests of valid form names and event names. The usual fall-back solution was to get all data.
|
* `read_redcap_tables()` **NEW**: this function is mainly an implementation of the combined use of `REDCapR::redcap_read()` and `REDCap_split()` to maintain the focused nature of `REDCapR::redcap_read()`, to only download the specified data. Also implements tests of valid form names and event names. The usual fall-back solution was to get all data.
|
||||||
|
|
||||||
* `redcap_wider()` **NEW**: this function pivots the long data frames from `read_redcap_tables()` using `tidyr::pivot_wider()`.
|
* `redcap_wider()` **NEW**: this function pivots the long data frames from `read_redcap_tables()` using `tidyr::pivot_wider()`.
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
utils::globalVariables(c(
|
utils::globalVariables(c(
|
||||||
"stats::setNames",
|
|
||||||
"field_name",
|
"field_name",
|
||||||
"field_type",
|
"field_type",
|
||||||
"select_choices_or_calculations",
|
"select_choices_or_calculations",
|
||||||
@ -247,7 +246,7 @@ ds2dd <-
|
|||||||
#' form.name = sample(c("b", "c"), size = 6, replace = TRUE, prob = rep(.5, 2))
|
#' form.name = sample(c("b", "c"), size = 6, replace = TRUE, prob = rep(.5, 2))
|
||||||
#' ) |>
|
#' ) |>
|
||||||
#' purrr::pluck("meta")
|
#' purrr::pluck("meta")
|
||||||
#' mtcars |> ds2dd_detailed(add.auto.id = TRUE)
|
#' mtcars |> numchar2fct() |> ds2dd_detailed(add.auto.id = TRUE)
|
||||||
#'
|
#'
|
||||||
#' ## Using column name suffix to carry form name
|
#' ## Using column name suffix to carry form name
|
||||||
#' data <- iris |>
|
#' data <- iris |>
|
||||||
@ -269,6 +268,10 @@ ds2dd_detailed <- function(data,
|
|||||||
metadata = names(REDCapCAST::redcapcast_meta),
|
metadata = names(REDCapCAST::redcapcast_meta),
|
||||||
convert.logicals = TRUE) {
|
convert.logicals = TRUE) {
|
||||||
|
|
||||||
|
short_names <- colnames(data) |> lapply(\(.x) cut_string_length(.x,l=90)) |> purrr::reduce(c)
|
||||||
|
|
||||||
|
data <- stats::setNames(data,short_names)
|
||||||
|
|
||||||
if (convert.logicals) {
|
if (convert.logicals) {
|
||||||
data <- data |>
|
data <- data |>
|
||||||
## Converts logical to factor, which overwrites attributes
|
## Converts logical to factor, which overwrites attributes
|
||||||
@ -294,7 +297,6 @@ ds2dd_detailed <- function(data,
|
|||||||
dplyr::tibble()
|
dplyr::tibble()
|
||||||
|
|
||||||
## form_name and field_name
|
## form_name and field_name
|
||||||
|
|
||||||
if (!is.null(form.sep)) {
|
if (!is.null(form.sep)) {
|
||||||
if (form.sep != "") {
|
if (form.sep != "") {
|
||||||
parts <- strsplit(names(data), split = form.sep)
|
parts <- strsplit(names(data), split = form.sep)
|
||||||
@ -313,11 +315,14 @@ ds2dd_detailed <- function(data,
|
|||||||
dd$field_name <- tolower(dd$field_name)
|
dd$field_name <- tolower(dd$field_name)
|
||||||
} else {
|
} else {
|
||||||
dd$form_name <- "data"
|
dd$form_name <- "data"
|
||||||
dd$field_name <- gsub(" ", "_", tolower(colnames(data)))
|
|
||||||
|
# dd$field_name <- gsub(" ", "_", tolower(colnames(data)))
|
||||||
|
dd$field_name <- clean_redcap_name(colnames(data))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
## if no form name prefix, the colnames are used as field_names
|
## if no form name prefix, the colnames are used as field_names
|
||||||
dd$field_name <- gsub(" ", "_", tolower(colnames(data)))
|
# dd$field_name <- gsub(" ", "_", tolower(colnames(data)))
|
||||||
|
dd$field_name <- clean_redcap_name(colnames(data))
|
||||||
|
|
||||||
if (is.null(form.name)) {
|
if (is.null(form.name)) {
|
||||||
dd$form_name <- "data"
|
dd$form_name <- "data"
|
||||||
@ -425,7 +430,14 @@ ds2dd_detailed <- function(data,
|
|||||||
out <- list(
|
out <- list(
|
||||||
data = data |>
|
data = data |>
|
||||||
hms2character() |>
|
hms2character() |>
|
||||||
stats::setNames(dd$field_name),
|
stats::setNames(dd$field_name) |>
|
||||||
|
lapply(\(.x){
|
||||||
|
if (identical("factor",class(.x))){
|
||||||
|
as.numeric(.x)
|
||||||
|
} else {
|
||||||
|
.x
|
||||||
|
}
|
||||||
|
}) |> dplyr::bind_cols(),
|
||||||
meta = dd
|
meta = dd
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,6 +28,9 @@ get_api_key <- function(key.name, ...) {
|
|||||||
#' \link[keyring]{key_set}, using the default keyring)
|
#' \link[keyring]{key_set}, using the default keyring)
|
||||||
#' @param widen.data argument to widen the exported data
|
#' @param widen.data argument to widen the exported data
|
||||||
#' @param uri REDCap database API uri
|
#' @param uri REDCap database API uri
|
||||||
|
#' @param raw_or_label argument passed on to
|
||||||
|
#' \link[REDCapCAST]{read_redcap_tables}. Default is "both" to get labelled
|
||||||
|
#' data.
|
||||||
#' @param ... arguments passed on to \link[REDCapCAST]{read_redcap_tables}.
|
#' @param ... arguments passed on to \link[REDCapCAST]{read_redcap_tables}.
|
||||||
#'
|
#'
|
||||||
#' @return data.frame or list depending on widen.data
|
#' @return data.frame or list depending on widen.data
|
||||||
@ -35,16 +38,22 @@ get_api_key <- function(key.name, ...) {
|
|||||||
#'
|
#'
|
||||||
#' @examples
|
#' @examples
|
||||||
#' \dontrun{
|
#' \dontrun{
|
||||||
#' easy_redcap("My_new_project",fields=c("record_id","age","hypertension"))
|
#' easy_redcap("My_new_project", fields = c("record_id", "age", "hypertension"))
|
||||||
#' }
|
#' }
|
||||||
easy_redcap <- function(project.name, widen.data = TRUE, uri, ...) {
|
easy_redcap <- function(project.name,
|
||||||
key <- get_api_key(key.name = paste0(project.name, "_REDCAP_API"),
|
widen.data = TRUE,
|
||||||
prompt = "Provide REDCap API key:")
|
uri,
|
||||||
|
raw_or_label = "both",
|
||||||
|
...) {
|
||||||
|
key <- get_api_key(
|
||||||
|
key.name = paste0(project.name, "_REDCAP_API"),
|
||||||
|
prompt = "Provide REDCap API key:"
|
||||||
|
)
|
||||||
|
|
||||||
out <- read_redcap_tables(
|
out <- read_redcap_tables(
|
||||||
uri = uri,
|
uri = uri,
|
||||||
token = key,
|
token = key,
|
||||||
raw_or_label = "both",
|
raw_or_label = raw_or_label,
|
||||||
...
|
...
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -47,6 +47,12 @@ file_extension <- function(filenames) {
|
|||||||
#' @return tibble
|
#' @return tibble
|
||||||
#' @export
|
#' @export
|
||||||
#'
|
#'
|
||||||
|
#' @importFrom openxlsx2 read_xlsx
|
||||||
|
#' @importFrom haven read_dta
|
||||||
|
#' @importFrom readODS read_ods
|
||||||
|
#' @importFrom readr read_csv read_rds
|
||||||
|
#'
|
||||||
|
#'
|
||||||
#' @examples
|
#' @examples
|
||||||
#' read_input("https://raw.githubusercontent.com/agdamsbo/cognitive.index.lookup/main/data/sample.csv")
|
#' read_input("https://raw.githubusercontent.com/agdamsbo/cognitive.index.lookup/main/data/sample.csv")
|
||||||
read_input <- function(file, consider.na = c("NA", '""', "")) {
|
read_input <- function(file, consider.na = c("NA", '""', "")) {
|
||||||
@ -55,15 +61,15 @@ read_input <- function(file, consider.na = c("NA", '""', "")) {
|
|||||||
tryCatch(
|
tryCatch(
|
||||||
{
|
{
|
||||||
if (ext == "csv") {
|
if (ext == "csv") {
|
||||||
df <- readr::read_csv(file = file, na = consider.na)
|
df <- read_csv(file = file, na = consider.na)
|
||||||
} else if (ext %in% c("xls", "xlsx")) {
|
} else if (ext %in% c("xls", "xlsx")) {
|
||||||
df <- openxlsx2::read_xlsx(file = file, na.strings = consider.na)
|
df <- read_xlsx(file = file, na.strings = consider.na)
|
||||||
} else if (ext == "dta") {
|
} else if (ext == "dta") {
|
||||||
df <- haven::read_dta(file = file)
|
df <- read_dta(file = file)
|
||||||
} else if (ext == "ods") {
|
} else if (ext == "ods") {
|
||||||
df <- readODS::read_ods(path = file)
|
df <- read_ods(path = file)
|
||||||
} else if (ext == "rds") {
|
} else if (ext == "rds") {
|
||||||
df <- readr::read_rds(file = file)
|
df <- read_rds(file = file)
|
||||||
}else {
|
}else {
|
||||||
stop("Input file format has to be on of:
|
stop("Input file format has to be on of:
|
||||||
'.csv', '.xls', '.xlsx', '.dta', '.ods' or '.rds'")
|
'.csv', '.xls', '.xlsx', '.dta', '.ods' or '.rds'")
|
||||||
|
23
R/utils.r
23
R/utils.r
@ -97,7 +97,10 @@ focused_metadata <- function(metadata, vars_in_data) {
|
|||||||
#' @return vector or data frame, same format as input
|
#' @return vector or data frame, same format as input
|
||||||
#' @export
|
#' @export
|
||||||
#'
|
#'
|
||||||
|
#' @examples
|
||||||
|
#' "Research!, ne:ws? and c;l-.ls" |> clean_redcap_name()
|
||||||
clean_redcap_name <- function(x) {
|
clean_redcap_name <- function(x) {
|
||||||
|
gsub("[,.;:?!@]","",
|
||||||
gsub(
|
gsub(
|
||||||
" ", "_",
|
" ", "_",
|
||||||
gsub(
|
gsub(
|
||||||
@ -108,6 +111,7 @@ clean_redcap_name <- function(x) {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -518,3 +522,22 @@ dummy_fun <- function(...){
|
|||||||
gtsummary::add_difference()
|
gtsummary::add_difference()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#' Cut string to desired length
|
||||||
|
#'
|
||||||
|
#' @param data data
|
||||||
|
#' @param l length
|
||||||
|
#'
|
||||||
|
#' @returns character string of length l
|
||||||
|
#' @export
|
||||||
|
#'
|
||||||
|
#' @examples
|
||||||
|
#' "length" |> cut_string_length(l=3)
|
||||||
|
cut_string_length <- function(data,l=100){
|
||||||
|
if (nchar(data)>=l){
|
||||||
|
substr(data,1,l)
|
||||||
|
} else {
|
||||||
|
data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -19,4 +19,5 @@ StripTrailingWhitespace: Yes
|
|||||||
BuildType: Package
|
BuildType: Package
|
||||||
PackageUseDevtools: Yes
|
PackageUseDevtools: Yes
|
||||||
PackageInstallArgs: --no-multiarch --with-keep.source
|
PackageInstallArgs: --no-multiarch --with-keep.source
|
||||||
|
PackageCheckArgs: --as-cran
|
||||||
PackageRoxygenize: rd,collate,namespace,vignette
|
PackageRoxygenize: rd,collate,namespace,vignette
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
── R CMD check results ─────────────────────────────────────────────────────────────────────────────── REDCapCAST 24.11.1 ────
|
── R CMD check results ─────────────────────────────────────────────────────────────────────── REDCapCAST 25.1.1 ────
|
||||||
Duration: 23.8s
|
Duration: 31.2s
|
||||||
|
|
||||||
0 errors ✔ | 0 warnings ✔ | 0 notes ✔
|
0 errors ✔ | 0 warnings ✔ | 0 notes ✔
|
||||||
|
|
||||||
R CMD check succeeded
|
R CMD check succeeded
|
||||||
|
|
||||||
## Test environments
|
## Test environments
|
||||||
Rhubv2 runs and checks out.
|
Rhubv2 runs and checks out.
|
||||||
|
@ -68,6 +68,7 @@ natively
|
|||||||
ncol
|
ncol
|
||||||
og
|
og
|
||||||
param
|
param
|
||||||
|
params
|
||||||
pegeler
|
pegeler
|
||||||
perl
|
perl
|
||||||
pos
|
pos
|
||||||
|
@ -5,6 +5,6 @@ account: agdamsbo
|
|||||||
server: shinyapps.io
|
server: shinyapps.io
|
||||||
hostUrl: https://api.shinyapps.io/v1
|
hostUrl: https://api.shinyapps.io/v1
|
||||||
appId: 11351429
|
appId: 11351429
|
||||||
bundleId: 9461113
|
bundleId: 9642648
|
||||||
url: https://agdamsbo.shinyapps.io/redcapcast/
|
url: https://agdamsbo.shinyapps.io/redcapcast/
|
||||||
version: 1
|
version: 1
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
\alias{REDCapCAST-package}
|
\alias{REDCapCAST-package}
|
||||||
\title{REDCapCAST: REDCap Metadata Casting and Castellated Data Handling}
|
\title{REDCapCAST: REDCap Metadata Casting and Castellated Data Handling}
|
||||||
\description{
|
\description{
|
||||||
\if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}}
|
|
||||||
|
|
||||||
Casting metadata for REDCap database creation and handling of castellated data using repeated instruments and longitudinal projects in 'REDCap'. Keeps a focused data export approach, by allowing to only export required data from the database. Also for casting new REDCap databases based on datasets from other sources. Originally forked from the R part of 'REDCapRITS' by Paul Egeler. See \url{https://github.com/pegeler/REDCapRITS}. 'REDCap' (Research Electronic Data Capture) is a secure, web-based software platform designed to support data capture for research studies, providing 1) an intuitive interface for validated data capture; 2) audit trails for tracking data manipulation and export procedures; 3) automated export procedures for seamless data downloads to common statistical packages; and 4) procedures for data integration and interoperability with external sources (Harris et al (2009) \doi{10.1016/j.jbi.2008.08.010}; Harris et al (2019) \doi{10.1016/j.jbi.2019.103208}).
|
Casting metadata for REDCap database creation and handling of castellated data using repeated instruments and longitudinal projects in 'REDCap'. Keeps a focused data export approach, by allowing to only export required data from the database. Also for casting new REDCap databases based on datasets from other sources. Originally forked from the R part of 'REDCapRITS' by Paul Egeler. See \url{https://github.com/pegeler/REDCapRITS}. 'REDCap' (Research Electronic Data Capture) is a secure, web-based software platform designed to support data capture for research studies, providing 1) an intuitive interface for validated data capture; 2) audit trails for tracking data manipulation and export procedures; 3) automated export procedures for seamless data downloads to common statistical packages; and 4) procedures for data integration and interoperability with external sources (Harris et al (2009) \doi{10.1016/j.jbi.2008.08.010}; Harris et al (2019) \doi{10.1016/j.jbi.2019.103208}).
|
||||||
}
|
}
|
||||||
\seealso{
|
\seealso{
|
||||||
|
@ -17,3 +17,6 @@ Stepwise removal on non-alphanumeric characters, trailing white space,
|
|||||||
substitutes spaces for underscores and converts to lower case.
|
substitutes spaces for underscores and converts to lower case.
|
||||||
Trying to make up for different naming conventions.
|
Trying to make up for different naming conventions.
|
||||||
}
|
}
|
||||||
|
\examples{
|
||||||
|
"Research!, ne:ws? and c;l-.ls" |> clean_redcap_name()
|
||||||
|
}
|
||||||
|
22
man/cut_string_length.Rd
Normal file
22
man/cut_string_length.Rd
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
% Generated by roxygen2: do not edit by hand
|
||||||
|
% Please edit documentation in R/utils.r
|
||||||
|
\name{cut_string_length}
|
||||||
|
\alias{cut_string_length}
|
||||||
|
\title{Cut string to desired length}
|
||||||
|
\usage{
|
||||||
|
cut_string_length(data, l = 100)
|
||||||
|
}
|
||||||
|
\arguments{
|
||||||
|
\item{data}{data}
|
||||||
|
|
||||||
|
\item{l}{length}
|
||||||
|
}
|
||||||
|
\value{
|
||||||
|
character string of length l
|
||||||
|
}
|
||||||
|
\description{
|
||||||
|
Cut string to desired length
|
||||||
|
}
|
||||||
|
\examples{
|
||||||
|
"length" |> cut_string_length(l=3)
|
||||||
|
}
|
@ -91,7 +91,7 @@ iris |>
|
|||||||
form.name = sample(c("b", "c"), size = 6, replace = TRUE, prob = rep(.5, 2))
|
form.name = sample(c("b", "c"), size = 6, replace = TRUE, prob = rep(.5, 2))
|
||||||
) |>
|
) |>
|
||||||
purrr::pluck("meta")
|
purrr::pluck("meta")
|
||||||
mtcars |> ds2dd_detailed(add.auto.id = TRUE)
|
mtcars |> numchar2fct() |> ds2dd_detailed(add.auto.id = TRUE)
|
||||||
|
|
||||||
## Using column name suffix to carry form name
|
## Using column name suffix to carry form name
|
||||||
data <- iris |>
|
data <- iris |>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
\alias{easy_redcap}
|
\alias{easy_redcap}
|
||||||
\title{Secure API key storage and data acquisition in one}
|
\title{Secure API key storage and data acquisition in one}
|
||||||
\usage{
|
\usage{
|
||||||
easy_redcap(project.name, widen.data = TRUE, uri, ...)
|
easy_redcap(project.name, widen.data = TRUE, uri, raw_or_label = "both", ...)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{project.name}{The name of the current project (for key storage with
|
\item{project.name}{The name of the current project (for key storage with
|
||||||
@ -14,6 +14,10 @@ easy_redcap(project.name, widen.data = TRUE, uri, ...)
|
|||||||
|
|
||||||
\item{uri}{REDCap database API uri}
|
\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{...}{arguments passed on to \link[REDCapCAST]{read_redcap_tables}.}
|
\item{...}{arguments passed on to \link[REDCapCAST]{read_redcap_tables}.}
|
||||||
}
|
}
|
||||||
\value{
|
\value{
|
||||||
@ -24,6 +28,6 @@ Secure API key storage and data acquisition in one
|
|||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
\dontrun{
|
\dontrun{
|
||||||
easy_redcap("My_new_project",fields=c("record_id","age","hypertension"))
|
easy_redcap("My_new_project", fields = c("record_id", "age", "hypertension"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 9.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 8.6 KiB |
@ -37,7 +37,7 @@ shiny_cast()
|
|||||||
|
|
||||||
To get you started, the easiest way possible, you can use the `easy_redcap()` function (example below).
|
To get you started, the easiest way possible, you can use the `easy_redcap()` function (example below).
|
||||||
|
|
||||||
You will need an API-key for your REDCap server, the uri/URL/address for the API connection (usually the adress used for accessing your institutions REDCap servar, with an appended "/api/").
|
You will need an API-key for your REDCap server, the uri/URL/address for the API connection (usually the address used for accessing your institutions REDCap server, with an appended "/api/").
|
||||||
|
|
||||||
This function includes a few convenience features to ease your further work.
|
This function includes a few convenience features to ease your further work.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user