mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2026-06-19 04:27:30 +02:00
reverting and recovering from renv corruption
This commit is contained in:
parent
99ed934cae
commit
2ad36d6dde
12 changed files with 78 additions and 128 deletions
31
R/helpers.R
31
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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue