minor changes

This commit is contained in:
Andreas Gammelgaard Damsbo 2024-02-27 12:43:54 +01:00
parent b63fbbe3c9
commit a7a416fe1d
9 changed files with 34 additions and 21 deletions

View File

@ -16,3 +16,4 @@
^cran-comments\.md$
^CRAN-SUBMISSION$
drafting
app

View File

@ -1,8 +1,11 @@
options(
renv.settings.snapshot.type = "explicit",
renv.config.auto.snapshot = TRUE,
renv.config.pak.enabled = TRUE
renv.config.pak.enabled = TRUE,
rmarkdown.html_vignette.check_title = FALSE
)
source("renv/activate.R")
if (interactive()) {

View File

@ -8,10 +8,9 @@ Authors@R: c(
comment = c(ORCID = "0000-0001-6948-9498")))
Description: Originally forked from the R part of 'REDCapRITS' by Paul Egeler.
See <https://github.com/pegeler/REDCapRITS>.
Handles castellated datasets from 'REDCap' projects with repeating instruments.
Assists in casting tidy tables from raw 'REDCap' data exports for each
repeated instrument. Keeps a focused data export approach, by allowing to
only export required data from the database.
'REDCap' database casting and handling of castellated data when using
repeated instruments and longitudinal projects. Keeps a focused data export
approach, by allowing to only export required data from the database.
'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
@ -22,7 +21,6 @@ Description: Originally forked from the R part of 'REDCapRITS' by Paul Egeler.
Harris et al (2019) <doi:10.1016/j.jbi.2019.103208>).
Depends: R (>= 3.4.0)
Suggests:
spelling,
httr,
jsonlite,
testthat,
@ -38,7 +36,9 @@ Suggests:
devtools,
roxygen2,
openxlsx2,
rsconnect
rsconnect,
shiny,
spelling
License: GPL (>= 3)
Encoding: UTF-8
LazyData: true
@ -61,6 +61,7 @@ Collate:
'ds2dd.R'
'ds2dd_detailed.R'
'easy_redcap.R'
'mtcars_redcap.R'
'read_redcap_instrument.R'
'read_redcap_tables.R'
'redcap_wider.R'

View File

@ -3,6 +3,7 @@
export(REDCap_split)
export(clean_redcap_name)
export(d2w)
export(deploy_shiny)
export(ds2dd)
export(ds2dd_detailed)
export(easy_redcap)

View File

@ -1,3 +1,4 @@
utils::globalVariables(c("server"))
#' Shiny server factory
#'
#' @return shiny server
@ -36,6 +37,9 @@ shiny_cast <- function() {
#' Deploy the Shiny app with rsconnect
#'
#' @param path app folder path
#' @param name.app name of deployed app
#'
#' @return deploy
#' @export
#'
@ -43,9 +47,6 @@ shiny_cast <- function() {
#' # deploy_shiny
#'
deploy_shiny <- function(path=here::here("app/"), name.app="shiny_cast"){
# Ensure to install latest package version
renv::install("agdamsbo/REDCapCAST")
# Connecting
rsconnect::setAccountInfo(
name = "cognitiveindex",

View File

@ -16,25 +16,27 @@ REDCap database casting and handling of castellated data when using repeated ins
This package is a fork of [pegeler/REDCapRITS](https://github.com/pegeler/REDCapRITS). The REDCapRITS represents great and extensive work to handle castellated REDCap data in different programming languages. This fork is purely minded on R usage and includes a few implementations of the main `REDCap_split` function.
THis package is very much to be seen as an attempt at a REDCap-R foundry for handling both the transition from dataset/variable list to database and the other way, from REDCap database to a tidy dataset. The goal was also to allow for a "minimal data" approach by allowing to filter records, instruments and variables in the export to only download data needed. I think this approach is desireable for handling sensitive, clinical data. No similar functionality is available from similar tools (like `REDCapR` or `REDCapTidieR`). Please refer to [REDCap-Tools](https://redcap-tools.github.io/) for other great tools.
This package is very much to be seen as an attempt at a R-to-REDCap-to-R foundry for handling both the transition from dataset/variable list to database and the other way, from REDCap database to a tidy dataset. The goal was also to allow for a "minimal data" approach by allowing to filter records, instruments and variables in the export to only download data needed. I think this approach is desirable for handling sensitive, clinical data. Please refer to [REDCap-Tools](https://redcap-tools.github.io/) for other great tools for working with REDCap in R.
## Use and immprovements
This package is primarily relevant for working with longitudinal projects and/or projects using repeated instruments. Here is just a short descirption of the main functions:
Here is just a short description of the main functions:
* `REDcap_split()`: Works largely as the original `REDCapRITS::REDCap_split()`. It takes a REDCap dataset and metadata (data dictionary) to split the data set into a list of dataframes of instruments.
* `read_redcap_tables()`: wraps the use of [`REDCapR::redcap_read()`](https://github.com/OuhscBbmc/REDCapR) with `REDCap_split()` to ease the export of REDCap data.
* `read_redcap_tables()`: wraps the use of [`REDCapR::redcap_read()`](https://github.com/OuhscBbmc/REDCapR) with `REDCap_split()` to ease the export of REDCap data. Default output is a list of data frames with one data frame for each REDCap instrument.
* `redcap_wider()`: pivots each data frame with repeated instruments to a wide format utilizing the [`tidyr::pivot_wider()`](https://tidyr.tidyverse.org/reference/pivot_wider.html) from the [tidyverse](https://www.tidyverse.org/).
* `redcap_wider()`: joins and pivots a list of data frames with repeated instruments to a wide format utilizing the [`tidyr::pivot_wider()`](https://tidyr.tidyverse.org/reference/pivot_wider.html) from the [tidyverse](https://www.tidyverse.org/).
* `easy_redcap()`: combines secure API key storage with the `keyring`-package, focused data retrieval and optional widening. This is the recommended approach for easy data access and analysis.
...
* `ds2dd_detailed()`: Converts a data set to a data dictionary for upload to a new REDCap database. Variables (fields) and instruments in a REDCap data base are defined by this data dictionary.
* `shiny_cast()`: [Shiny]() application to ease the process of converting a spreadsheet/data set to a REDCap database. The app runs locally and data is transferred securely. You can just create and upload the data dictionary, but you can also transfer the given data in the same process.
## Future
The plan with this package is to be bundled with a Handbook on working with REDCap from R. I plan to also include functionality to assist in casting (yes, pun intended) the initial REDCap database.
The plan with this package is to be bundled with a Handbook on working with REDCap from R. This work is in progress but is limited by the time available. Please feel free to contact me or create and issue with ideas for future additions.
## Installation

View File

@ -18,4 +18,4 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace,vignette
PackageRoxygenize: rd,collate,namespace

View File

@ -40,12 +40,12 @@ ui <- shiny::fluidPage(
shiny::textInput(
inputId = "uri",
label = "URI",
value = "https://redcap.au.dk/api/"
value = "https://redcap.your.institution/api/"
),
shiny::textInput(
inputId = "api",
label = "API key",
value = "21CF2C17EA1CA4F3688DF991C8FE3EBF"
value = ""
),
shiny::actionButton(
inputId = "upload.meta",

View File

@ -1,5 +1,9 @@
mtcars |> dplyr::mutate(record_id=seq_len(n()),
mtcars_redcap <- mtcars |> dplyr::mutate(record_id=seq_len(dplyr::n()),
name=rownames(mtcars)
) |>
dplyr::select(record_id,dplyr::everything()) |>
dplyr::select(record_id,dplyr::everything())
mtcars_redcap |>
write.csv(here::here("data/mtcars_redcap.csv"),row.names = FALSE)
usethis::use_data(mtcars_redcap, overwrite = TRUE)