From 9d53f84427e119c10fb79746ccedb619618dd8ac Mon Sep 17 00:00:00 2001 From: Andreas Gammelgaard Damsbo Date: Mon, 18 Nov 2024 14:41:44 +0100 Subject: [PATCH] docs and name update --- DESCRIPTION | 3 ++- NAMESPACE | 6 ++++++ inst/shiny-examples/casting/server.R | 3 ++- man/REDCapCAST-package.Rd | 2 +- vignettes/Database-creation.Rmd | 2 +- vignettes/REDCapCAST.Rmd | 2 +- vignettes/Shiny-app.Rmd | 31 +++++++++++++++++++++++----- 7 files changed, 39 insertions(+), 10 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d231029..28ad56f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -58,7 +58,8 @@ Imports: zip, assertthat, openxlsx2, - readODS + readODS, + forcats Collate: 'REDCapCAST-package.R' 'utils.r' diff --git a/NAMESPACE b/NAMESPACE index 36cc88d..42d9bc1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -20,10 +20,14 @@ export(file_extension) export(focused_metadata) export(format_subheader) export(get_api_key) +export(guess_time_only) export(guess_time_only_filter) +export(haven_all_levels) export(html_tag_wrap) export(is_repeated_longitudinal) export(match_fields_to_form) +export(numchar2fct) +export(parse_data) export(process_user_input) export(read_input) export(read_redcap_instrument) @@ -33,9 +37,11 @@ export(sanitize_split) export(shiny_cast) export(split_non_repeating_forms) export(strsplitx) +export(var2fct) importFrom(REDCapR,redcap_event_instruments) importFrom(REDCapR,redcap_metadata_read) importFrom(REDCapR,redcap_read) +importFrom(forcats,as_factor) importFrom(keyring,key_get) importFrom(keyring,key_list) importFrom(keyring,key_set) diff --git a/inst/shiny-examples/casting/server.R b/inst/shiny-examples/casting/server.R index 161976d..119e198 100644 --- a/inst/shiny-examples/casting/server.R +++ b/inst/shiny-examples/casting/server.R @@ -17,7 +17,8 @@ server <- function(input, output, session) { dat <- shiny::reactive({ shiny::req(input$ds) - read_input(input$ds$datapath) + read_input(input$ds$datapath) |> + parse_data() }) # getData <- reactive({ diff --git a/man/REDCapCAST-package.Rd b/man/REDCapCAST-package.Rd index f0117d7..da4a544 100644 --- a/man/REDCapCAST-package.Rd +++ b/man/REDCapCAST-package.Rd @@ -4,7 +4,7 @@ \name{REDCapCAST-package} \alias{REDCapCAST} \alias{REDCapCAST-package} -\title{REDCapCAST: REDCap Castellated Data Handling And Metadata Casting} +\title{REDCapCAST: REDCap Castellated Data Handling and Metadata Casting} \description{ \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} diff --git a/vignettes/Database-creation.Rmd b/vignettes/Database-creation.Rmd index 4967051..7c7327c 100644 --- a/vignettes/Database-creation.Rmd +++ b/vignettes/Database-creation.Rmd @@ -45,7 +45,7 @@ The more advanced `ds2dd_detailed()` is a natural development. It will try to ap The dataset should be correctly formatted for the data dictionary to preserve as much information as possible. -```{r eval=TRUE} +```{r eval=FALSE} d2 <- REDCapCAST::redcapcast_data |> dplyr::mutate(record_id = seq_len(dplyr::n()), region=factor(region)) |> diff --git a/vignettes/REDCapCAST.Rmd b/vignettes/REDCapCAST.Rmd index c9ea11a..0b782a3 100644 --- a/vignettes/REDCapCAST.Rmd +++ b/vignettes/REDCapCAST.Rmd @@ -2,7 +2,7 @@ title: "REDCapCAST" output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{Introduction} + %\VignetteIndexEntry{REDCapCAST} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- diff --git a/vignettes/Shiny-app.Rmd b/vignettes/Shiny-app.Rmd index acb4dd7..34a43b6 100644 --- a/vignettes/Shiny-app.Rmd +++ b/vignettes/Shiny-app.Rmd @@ -14,13 +14,34 @@ knitr::opts_chunk$set( ) ``` -To make the easiest possible transition from spreadsheet/dataset to REDCap, I have created a small Shiny app, which adds a graphical interface to the casting of a data dictionary and data upload. Install the package and run the app as follows: +To make the easiest possible transition from spreadsheet/dataset to REDCap, I have created a small app, which adds a graphical interface to the casting of a data dictionary and data upload. Install the package and launch the app as follows: ```{r eval=FALSE} -require(REDCapCAST) -shiny_cast() +REDCapCAST::shiny_cast() +``` + +The app primarily wraps one function: `ds2dd_detailed()`. + +```{r} +REDCap_split( + records = redcapcast_data, + metadata = redcapcast_meta, + forms = "all" + ) |> + sanitize_split() |> + redcap_wider() |> + ds2dd_detailed()|> + purrr::pluck("data") |> + readr::type_convert( + col_types = readr::cols(.default = readr::col_guess())) +``` + + +```{r} +redcapcast_data |> + dplyr::mutate(dplyr::across(dplyr::everything(),as.character)) |> + readr::type_convert( + col_types = readr::cols(.default = readr::col_guess())) ``` -The app will launch in a new window and the interface should be fairly self-explanatory. -The app only provides the most basic functionality, but might be extended in the future.