From 2ad36d6dde02d9f56e145a42ad67adac01e24d83 Mon Sep 17 00:00:00 2001 From: Andreas Gammelgaard Damsbo Date: Thu, 19 Dec 2024 21:21:29 +0100 Subject: [PATCH] reverting and recovering from renv corruption --- DESCRIPTION | 9 ++- NAMESPACE | 6 -- R/helpers.R | 31 +++---- R/redcap_read_shiny_module.R | 7 +- R/regression_model.R | 3 +- inst/apps/data_analysis/server.R | 13 +-- inst/apps/data_analysis_modules/app.R | 81 +++++++------------ .../shinyapps.io/agdamsbo/freesearcheR.dcf | 2 +- inst/apps/data_analysis_modules/server.R | 13 +-- inst/apps/data_analysis_modules/ui.R | 4 +- man/default_parsing.Rd | 6 +- renv.lock | 31 ++++--- 12 files changed, 78 insertions(+), 128 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c2d3250..76cfb3c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -45,13 +45,18 @@ Imports: lubridate, bsicons, thematic, - reshape2 + reshape2, + shinyWidgets, + classInt, + htmltools, + rlang Suggests: styler, devtools, rhub, usethis, roxygen2, - pak + pak, + rsconnect URL: https://github.com/agdamsbo/freesearcheR BugReports: https://github.com/agdamsbo/freesearcheR/issues diff --git a/NAMESPACE b/NAMESPACE index 800bc03..513c28e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -28,12 +28,6 @@ export(specify_qmd_format) export(tbl_merge) export(winbox_cut_variable) export(write_quarto) -importFrom(REDCapCAST,as_factor) -importFrom(REDCapCAST,numchar2fct) -importFrom(REDCapCAST,parse_data) -importFrom(REDCapCAST,read_redcap_tables) -importFrom(REDCapCAST,redcap_wider) -importFrom(REDCapCAST,suffix2label) importFrom(classInt,classIntervals) importFrom(graphics,abline) importFrom(graphics,axis) diff --git a/R/helpers.R b/R/helpers.R index a99f382..95e21b2 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -98,7 +98,6 @@ argsstring2list <- function(string) { #' @param vars variables to force factorize #' #' @return data.frame -#' @importFrom REDCapCAST as_factor #' @export factorize <- function(data, vars) { if (!is.null(vars)) { @@ -106,7 +105,7 @@ factorize <- function(data, vars) { dplyr::mutate( dplyr::across( dplyr::all_of(vars), - as_factor + REDCapCAST::as_factor ) ) } else { @@ -138,7 +137,6 @@ dummy_Imports <- function() { #' #' @returns data #' @export -#' @importFrom REDCapCAST as_factor parse_data numchar2fct #' file_export <- function(data, output.format = c("df", "teal", "list"), filename, ...) { output.format <- match.arg(output.format) @@ -151,9 +149,7 @@ file_export <- function(data, output.format = c("df", "teal", "list"), filename, { assign(name, value |> dplyr::bind_cols() |> - parse_data() |> - as_factor() |> - numchar2fct()) + default_parsing()) }, value = data, name = filename @@ -161,17 +157,15 @@ file_export <- function(data, output.format = c("df", "teal", "list"), filename, datanames(out) <- filename } else if (output.format == "df") { - out <- data|> - parse_data() |> - as_factor() |> - numchar2fct() + out <- data |> + default_parsing() } else if (output.format == "list") { out <- list( data = data, name = filename ) - out <- c(out,...) + out <- c(out, ...) } out @@ -180,18 +174,19 @@ file_export <- function(data, output.format = c("df", "teal", "list"), filename, #' Default data parsing #' -#' @param data +#' @param data data #' #' @returns data.frame or tibble #' @export -#' @importFrom REDCapCAST as_factor parse_data numchar2fct #' #' @examples #' mtcars |> str() -#' mtcars |> default_parsing() |> str() -default_parsing <- function(data){ +#' mtcars |> +#' default_parsing() |> +#' str() +default_parsing <- function(data) { data |> - parse_data() |> - as_factor() |> - numchar2fct() + REDCapCAST::parse_data() |> + REDCapCAST::as_factor() |> + REDCapCAST::numchar2fct() } diff --git a/R/redcap_read_shiny_module.R b/R/redcap_read_shiny_module.R index b486498..061a6e7 100644 --- a/R/redcap_read_shiny_module.R +++ b/R/redcap_read_shiny_module.R @@ -100,7 +100,6 @@ m_redcap_readUI <- function(id, include_title = TRUE) { #' #' @return shiny server module #' @export -#' @importFrom REDCapCAST read_redcap_tables redcap_wider suffix2label #' m_redcap_readServer <- function(id, output.format = c("df", "teal", "list")) { output.format <- match.arg(output.format) @@ -227,7 +226,7 @@ m_redcap_readServer <- function(id, output.format = c("df", "teal", "list")) { shiny::req(input$fields) record_id <- dd()[[1]][1] - redcap_data <- read_redcap_tables( + redcap_data <- REDCapCAST::read_redcap_tables( uri = input$uri, token = input$api, fields = unique(c(record_id, input$fields)), @@ -236,10 +235,10 @@ m_redcap_readServer <- function(id, output.format = c("df", "teal", "list")) { raw_or_label = "both", filter_logic = input$filter ) |> - redcap_wider() |> + REDCapCAST::redcap_wider() |> dplyr::select(-dplyr::ends_with("_complete")) |> dplyr::select(-dplyr::any_of(record_id)) |> - suffix2label() + REDCapCAST::suffix2label() out_object <- file_export(redcap_data, output.format = output.format, diff --git a/R/regression_model.R b/R/regression_model.R index 8d6f188..d9d4529 100644 --- a/R/regression_model.R +++ b/R/regression_model.R @@ -10,7 +10,6 @@ #' @param ... ignored for now #' #' @importFrom stats as.formula -#' @importFrom REDCapCAST as_factor #' #' @return object of standard class for fun #' @export @@ -67,7 +66,7 @@ regression_model <- function(data, data <- data |> purrr::map(\(.x){ if (is.character(.x)) { - suppressWarnings(as_factor(.x)) + suppressWarnings(REDCapCAST::as_factor(.x)) } else { .x } diff --git a/inst/apps/data_analysis/server.R b/inst/apps/data_analysis/server.R index 45361d1..431e337 100644 --- a/inst/apps/data_analysis/server.R +++ b/inst/apps/data_analysis/server.R @@ -28,17 +28,6 @@ if (file.exists(here::here("functions.R"))) { source(here::here("functions.R")) } -#' freesearcheR server -#' -#' @param input input -#' @param output output -#' @param session session -#' -#' @returns server -#' @export -#' @importFrom REDCapCAST numchar2fct -#' -#' @examples server <- function(input, output, session) { ## Listing files in www in session start to keep when ending and removing ## everything else. @@ -75,7 +64,7 @@ server <- function(input, output, session) { out <- out |> (\(.x){ suppressWarnings( - numchar2fct(.x) + REDCapCAST::numchar2fct(.x) ) })() } diff --git a/inst/apps/data_analysis_modules/app.R b/inst/apps/data_analysis_modules/app.R index 5acd7c6..eb6b180 100644 --- a/inst/apps/data_analysis_modules/app.R +++ b/inst/apps/data_analysis_modules/app.R @@ -1,13 +1,13 @@ ######## -#### Current file: /Users/au301842/freesearcheR/inst/apps/data_analysis_modules/functions.R +#### Current file: /Users/au301842/freesearcheR/inst/apps/data_analysis_modules/functions.R ######## ######## -#### Current file: R//baseline_table.R +#### Current file: R//baseline_table.R ######## @@ -35,7 +35,7 @@ baseline_table <- function(data, fun.args = NULL, fun = gtsummary::tbl_summary, ######## -#### Current file: R//cut-variable-dates.R +#### Current file: R//cut-variable-dates.R ######## library(datamods) @@ -677,7 +677,7 @@ plot_histogram <- function(data, column, bins = 30, breaks = NULL, color = "#112 ######## -#### Current file: R//file-import-module.R +#### Current file: R//file-import-module.R ######## @@ -808,7 +808,7 @@ plot_histogram <- function(data, column, bins = 30, breaks = NULL, color = "#112 ######## -#### Current file: R//helpers.R +#### Current file: R//helpers.R ######## @@ -912,14 +912,13 @@ argsstring2list <- function(string) { - factorize <- function(data, vars) { if (!is.null(vars)) { data |> dplyr::mutate( dplyr::across( dplyr::all_of(vars), - as_factor + REDCapCAST::as_factor ) ) } else { @@ -952,8 +951,6 @@ dummy_Imports <- function() { - - file_export <- function(data, output.format = c("df", "teal", "list"), filename, ...) { output.format <- match.arg(output.format) @@ -965,9 +962,7 @@ file_export <- function(data, output.format = c("df", "teal", "list"), filename, { assign(name, value |> dplyr::bind_cols() |> - parse_data() |> - as_factor() |> - numchar2fct()) + default_parsing()) }, value = data, name = filename @@ -975,17 +970,15 @@ file_export <- function(data, output.format = c("df", "teal", "list"), filename, datanames(out) <- filename } else if (output.format == "df") { - out <- data|> - parse_data() |> - as_factor() |> - numchar2fct() + out <- data |> + default_parsing() } else if (output.format == "list") { out <- list( data = data, name = filename ) - out <- c(out,...) + out <- c(out, ...) } out @@ -1003,16 +996,17 @@ file_export <- function(data, output.format = c("df", "teal", "list"), filename, -default_parsing <- function(data){ + +default_parsing <- function(data) { data |> - parse_data() |> - as_factor() |> - numchar2fct() + REDCapCAST::parse_data() |> + REDCapCAST::as_factor() |> + REDCapCAST::numchar2fct() } ######## -#### Current file: R//redcap_read_shiny_module.R +#### Current file: R//redcap_read_shiny_module.R ######## @@ -1118,7 +1112,6 @@ m_redcap_readUI <- function(id, include_title = TRUE) { - m_redcap_readServer <- function(id, output.format = c("df", "teal", "list")) { output.format <- match.arg(output.format) @@ -1244,7 +1237,7 @@ m_redcap_readServer <- function(id, output.format = c("df", "teal", "list")) { shiny::req(input$fields) record_id <- dd()[[1]][1] - redcap_data <- read_redcap_tables( + redcap_data <- REDCapCAST::read_redcap_tables( uri = input$uri, token = input$api, fields = unique(c(record_id, input$fields)), @@ -1253,10 +1246,10 @@ m_redcap_readServer <- function(id, output.format = c("df", "teal", "list")) { raw_or_label = "both", filter_logic = input$filter ) |> - redcap_wider() |> + REDCapCAST::redcap_wider() |> dplyr::select(-dplyr::ends_with("_complete")) |> dplyr::select(-dplyr::any_of(record_id)) |> - suffix2label() + REDCapCAST::suffix2label() out_object <- file_export(redcap_data, output.format = output.format, @@ -1383,7 +1376,7 @@ redcap_app <- function() { ######## -#### Current file: R//regression_model.R +#### Current file: R//regression_model.R ######## @@ -1417,7 +1410,6 @@ redcap_app <- function() { - regression_model <- function(data, @@ -1455,7 +1447,7 @@ regression_model <- function(data, data <- data |> purrr::map(\(.x){ if (is.character(.x)) { - suppressWarnings(as_factor(.x)) + suppressWarnings(REDCapCAST::as_factor(.x)) } else { .x } @@ -1594,7 +1586,7 @@ regression_model_uv <- function(data, ######## -#### Current file: R//regression_table.R +#### Current file: R//regression_table.R ######## @@ -1742,7 +1734,7 @@ tbl_merge <- function(data) { ######## -#### Current file: R//report.R +#### Current file: R//report.R ######## @@ -1829,7 +1821,7 @@ modify_qmd <- function(file, format) { ######## -#### Current file: R//shiny_freesearcheR.R +#### Current file: R//shiny_freesearcheR.R ######## @@ -1860,7 +1852,7 @@ shiny_freesearcheR <- function(...) { ######## -#### Current file: R//theme.R +#### Current file: R//theme.R ######## @@ -1901,7 +1893,7 @@ custom_theme <- function(..., ######## -#### Current file: /Users/au301842/freesearcheR/inst/apps/data_analysis_modules/ui.R +#### Current file: /Users/au301842/freesearcheR/inst/apps/data_analysis_modules/ui.R ######## # ns <- NS(id) @@ -2213,7 +2205,7 @@ ui <- bslib::page_fluid( title = "freesearcheR", theme = light, shiny::useBusyIndicators(), - bslib::page_navbar( + bslib::page_navbar(title = "freesearcheR", id = "main_panel", # header = shiny::tags$header(shiny::p("Data is only stored temporarily for analysis and deleted immediately afterwards.")), ui_elements$import, @@ -2221,7 +2213,7 @@ ui <- bslib::page_fluid( ui_elements$analyze, ui_elements$docs, # bslib::nav_spacer(), - # bslib::nav_item(shinyWidgets::materialSwitch(inputId = "mode", label = icon("moon"), right=TRUE,status = "success")), + # bslib::nav_item(shinyWidgets::circleButton(inputId = "mode", icon = icon("moon"),status = "primary")), fillable = TRUE, footer = shiny::tags$footer( style = "background-color: #14131326; padding: 4px; text-align: center; bottom: 0; width: 100%;", @@ -2238,7 +2230,7 @@ ui <- bslib::page_fluid( ######## -#### Current file: /Users/au301842/freesearcheR/inst/apps/data_analysis_modules/server.R +#### Current file: /Users/au301842/freesearcheR/inst/apps/data_analysis_modules/server.R ######## library(readr) @@ -2277,17 +2269,6 @@ library(DT) # dark <- custom_theme(bg = "#000",fg="#fff") -#' freesearcheR server -#' -#' @param input input -#' @param output output -#' @param session session -#' -#' @returns server -#' @export -#' @importFrom REDCapCAST fct_drop.data.frame -#' -#' @examples server <- function(input, output, session) { ## Listing files in www in session start to keep when ending and removing ## everything else. @@ -2579,7 +2560,7 @@ server <- function(input, output, session) { { data <- data_filter() |> dplyr::mutate(dplyr::across(dplyr::where(is.character), as.factor)) |> - fct_drop.data.frame() |> + REDCapCAST::fct_drop.data.frame() |> factorize(vars = input$factor_vars) if (input$strat_var == "none") { @@ -2799,7 +2780,7 @@ server <- function(input, output, session) { ######## -#### Current file: /Users/au301842/freesearcheR/inst/apps/data_analysis_modules/launch.R +#### Current file: /Users/au301842/freesearcheR/inst/apps/data_analysis_modules/launch.R ######## shinyApp(ui, server) diff --git a/inst/apps/data_analysis_modules/rsconnect/shinyapps.io/agdamsbo/freesearcheR.dcf b/inst/apps/data_analysis_modules/rsconnect/shinyapps.io/agdamsbo/freesearcheR.dcf index 8d0b399..07d9f7c 100644 --- a/inst/apps/data_analysis_modules/rsconnect/shinyapps.io/agdamsbo/freesearcheR.dcf +++ b/inst/apps/data_analysis_modules/rsconnect/shinyapps.io/agdamsbo/freesearcheR.dcf @@ -5,6 +5,6 @@ account: agdamsbo server: shinyapps.io hostUrl: https://api.shinyapps.io/v1 appId: 13611288 -bundleId: +bundleId: 9546880 url: https://agdamsbo.shinyapps.io/freesearcheR/ version: 1 diff --git a/inst/apps/data_analysis_modules/server.R b/inst/apps/data_analysis_modules/server.R index 719a763..43a14bc 100644 --- a/inst/apps/data_analysis_modules/server.R +++ b/inst/apps/data_analysis_modules/server.R @@ -34,17 +34,6 @@ library(DT) # dark <- custom_theme(bg = "#000",fg="#fff") -#' freesearcheR server -#' -#' @param input input -#' @param output output -#' @param session session -#' -#' @returns server -#' @export -#' @importFrom REDCapCAST fct_drop.data.frame -#' -#' @examples server <- function(input, output, session) { ## Listing files in www in session start to keep when ending and removing ## everything else. @@ -336,7 +325,7 @@ server <- function(input, output, session) { { data <- data_filter() |> dplyr::mutate(dplyr::across(dplyr::where(is.character), as.factor)) |> - fct_drop.data.frame() |> + REDCapCAST::fct_drop.data.frame() |> factorize(vars = input$factor_vars) if (input$strat_var == "none") { diff --git a/inst/apps/data_analysis_modules/ui.R b/inst/apps/data_analysis_modules/ui.R index f16edd6..7471e72 100644 --- a/inst/apps/data_analysis_modules/ui.R +++ b/inst/apps/data_analysis_modules/ui.R @@ -307,7 +307,7 @@ ui <- bslib::page_fluid( title = "freesearcheR", theme = light, shiny::useBusyIndicators(), - bslib::page_navbar( + bslib::page_navbar(title = "freesearcheR", id = "main_panel", # header = shiny::tags$header(shiny::p("Data is only stored temporarily for analysis and deleted immediately afterwards.")), ui_elements$import, @@ -315,7 +315,7 @@ ui <- bslib::page_fluid( ui_elements$analyze, ui_elements$docs, # bslib::nav_spacer(), - # bslib::nav_item(shinyWidgets::materialSwitch(inputId = "mode", label = icon("moon"), right=TRUE,status = "success")), + # bslib::nav_item(shinyWidgets::circleButton(inputId = "mode", icon = icon("moon"),status = "primary")), fillable = TRUE, footer = shiny::tags$footer( style = "background-color: #14131326; padding: 4px; text-align: center; bottom: 0; width: 100%;", diff --git a/man/default_parsing.Rd b/man/default_parsing.Rd index b1ad21d..d7237c2 100644 --- a/man/default_parsing.Rd +++ b/man/default_parsing.Rd @@ -7,7 +7,7 @@ default_parsing(data) } \arguments{ -\item{data}{} +\item{data}{data} } \value{ data.frame or tibble @@ -17,5 +17,7 @@ Default data parsing } \examples{ mtcars |> str() -mtcars |> default_parsing() |> str() +mtcars |> + default_parsing() |> + str() } diff --git a/renv.lock b/renv.lock index 0868c9d..15e502d 100644 --- a/renv.lock +++ b/renv.lock @@ -193,13 +193,9 @@ }, "REDCapCAST": { "Package": "REDCapCAST", - "Version": "24.11.3", - "Source": "GitHub", - "RemoteType": "github", - "RemoteHost": "api.github.com", - "RemoteRepo": "REDCapCAST", - "RemoteUsername": "agdamsbo", - "RemoteSha": "45315080c596d3c1ea5f2e815ef27d2a50230326", + "Version": "24.12.1", + "Source": "Repository", + "Repository": "CRAN", "Requirements": [ "R", "REDCapR", @@ -209,6 +205,7 @@ "forcats", "glue", "gt", + "gtsummary", "haven", "here", "keyring", @@ -223,7 +220,7 @@ "vctrs", "zip" ], - "Hash": "9a9744292f30f1fb7fad55c2dd2e9baf" + "Hash": "d0925e579ddfbedeb536c5cbf65fc42f" }, "REDCapR": { "Package": "REDCapR", @@ -555,9 +552,9 @@ }, "cardx": { "Package": "cardx", - "Version": "0.2.1", + "Version": "0.2.2", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "cards", @@ -568,7 +565,7 @@ "rlang", "tidyr" ], - "Hash": "e5458dd65b0602136b16aed802d3bd50" + "Hash": "21f5ce5381d529b08783dca434af3003" }, "cellranger": { "Package": "cellranger", @@ -1593,7 +1590,7 @@ }, "lubridate": { "Package": "lubridate", - "Version": "1.9.3", + "Version": "1.9.4", "Source": "Repository", "Repository": "CRAN", "Requirements": [ @@ -1602,7 +1599,7 @@ "methods", "timechange" ], - "Hash": "680ad542fbcf801442c83a6ac5a2126c" + "Hash": "be38bc740fc51783a78edb5a157e4104" }, "magrittr": { "Package": "magrittr", @@ -1790,7 +1787,7 @@ }, "openxlsx2": { "Package": "openxlsx2", - "Version": "1.11", + "Version": "1.12", "Source": "Repository", "Repository": "CRAN", "Requirements": [ @@ -1803,7 +1800,7 @@ "utils", "zip" ], - "Hash": "c519244e5080a630292e1fdc36717f0d" + "Hash": "be241f0f1a58220243d69141407a97ac" }, "parameters": { "Package": "parameters", @@ -2547,10 +2544,10 @@ }, "sodium": { "Package": "sodium", - "Version": "1.3.2", + "Version": "1.4.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "869b09ca565ecaa9efc62534ebfa3efd" + "Hash": "ae00d33a499e429a04409bc1167c4995" }, "sourcetools": { "Package": "sourcetools",