This commit is contained in:
Andreas Gammelgaard Damsbo 2025-03-19 09:14:36 +01:00
commit 04784a7a24
No known key found for this signature in database
34 changed files with 121 additions and 137 deletions

View file

@ -1 +1 @@
app_version <- function()'250318_0819'
app_version <- function()'250318_0827'

View file

@ -254,7 +254,7 @@ import_file_server <- function(id,
parameters <- parameters[which(names(parameters) %in% rlang::fn_fmls_names(get(read_fns[[extension]])))]
# parameters <- parameters[which(names(parameters) %in% rlang::fn_fmls_names(read_fns[[extension]]))]
imported <- try(rlang::exec(read_fns[[extension]], !!!parameters), silent = TRUE)
code <- rlang::call2(read_fns[[extension]], !!!modifyList(parameters, list(file = input$file$name)), .ns = "freesearcheR")
code <- rlang::call2(read_fns[[extension]], !!!modifyList(parameters, list(file = input$file$name)), .ns = "FreesearchR")
if (inherits(imported, "try-error")) {
imported <- try(rlang::exec(rio::import, !!!parameters[1]), silent = TRUE)

24
R/launch_FreesearchR.R Normal file
View file

@ -0,0 +1,24 @@
#' Easily launch the FreesearchR app
#'
#' @description
#' All data.frames in the global environment will be accessible through the app.
#'
#' @param ... passed on to `shiny::runApp()`
#'
#' @returns shiny app
#' @export
#'
#' @examples
#' \dontrun{
#' data(mtcars)
#' shiny_FreesearchR(launch.browser = TRUE)
#' }
launch_FreesearchR <- function(...){
appDir <- system.file("apps", "FreesearchR", package = "FreesearchR")
if (appDir == "") {
stop("Could not find the app directory. Try re-installing `FreesearchR`.", call. = FALSE)
}
a <- shiny::runApp(appDir = paste0(appDir,"/app.R"), ...)
return(invisible(a))
}

View file

@ -15,15 +15,16 @@
#'
#' @examples
#' \dontrun{
#' mod <- lm(mpg ~ ., mtcars)
#' mod <- lm(mpg ~ ., default_parsing(mtcars))
#' p <- mod |>
#' gtsummary::tbl_regression() |>
#' plot(colour = "variable")
#' }
#'
plot.tbl_regression <- function(x,
# remove_header_rows = TRUE,
# remove_reference_rows = FALSE,
plot_ref = TRUE,
remove_header_rows = TRUE,
remove_reference_rows = FALSE,
...) {
# check_dots_empty()
gtsummary:::check_pkg_installed("ggstats")
@ -32,18 +33,22 @@ plot.tbl_regression <- function(x,
# gtsummary:::check_scalar_logical(remove_reference_rows)
df_coefs <- x$table_body
# if (isTRUE(remove_header_rows)) {
# df_coefs <- df_coefs |> dplyr::filter(!.data$header_row %in% TRUE)
# }
# if (isTRUE(remove_reference_rows)) {
# df_coefs <- df_coefs |> dplyr::filter(!.data$reference_row %in% TRUE)
# }
# browser()
browser()
if (isTRUE(remove_header_rows)) {
df_coefs <- df_coefs |> dplyr::filter(!header_row %in% TRUE)
}
if (isTRUE(remove_reference_rows)) {
df_coefs <- df_coefs |> dplyr::filter(!reference_row %in% TRUE)
}
# Removes redundant label
df_coefs$label[df_coefs$row_type == "label"] <- ""
df_coefs %>%
# Add estimate value to reference level
if (plot_ref == TRUE){
df_coefs[df_coefs$var_type == "categorical" & is.na(df_coefs$reference_row),"estimate"] <- if (x$inputs$exponentiate) 1 else 0}
df_coefs |>
ggstats::ggcoef_plot(exponentiate = x$inputs$exponentiate, ...)
}

View file

@ -81,7 +81,7 @@
#' #' @export
#' regression_table.default <- function(x, ..., args.list = NULL, fun = "gtsummary::tbl_regression") {
#' # Stripping custom class
#' class(x) <- class(x)[class(x) != "freesearcher_model"]
#' class(x) <- class(x)[class(x) != "freesearchr_model"]
#'
#' if (any(c(length(class(x)) != 1, class(x) != "lm"))) {
#' if (!"exponentiate" %in% names(args.list)) {
@ -110,7 +110,7 @@ regression_table <- function(x, ...) {
regression_table_create <- function(x, ..., args.list = NULL, fun = "gtsummary::tbl_regression") {
# Stripping custom class
class(x) <- class(x)[class(x) != "freesearcher_model"]
class(x) <- class(x)[class(x) != "freesearchr_model"]
if (any(c(length(class(x)) != 1, class(x) != "lm"))) {
if (!"exponentiate" %in% names(args.list)) {

View file

@ -1,37 +0,0 @@
#' Launch the freesearcheR tool locally
#'
#' @description
#' All data.frames in the global environment will be accessible through the app.
#'
#'
#' @param ... arguments passed on to `shiny::runApp()`
#'
#' @return shiny app
#' @export
#'
#' @examples
#' \dontrun{
#' data(mtcars)
#' shiny_freesearcheR(launch.browser = TRUE)
#' }
shiny_freesearcheR <- function(...) {
appDir <- system.file("apps", "freesearcheR", package = "freesearcheR")
if (appDir == "") {
stop("Could not find the app directory. Try re-installing `freesearcheR`.", call. = FALSE)
}
a <- shiny::runApp(appDir = paste0(appDir,"/app.R"), ...)
return(invisible(a))
}
#' Easily launch the freesearcheR app
#'
#' @param ... passed on to `shiny::runApp()`
#'
#' @returns shiny app
#' @export
#'
launch_freesearcheR <- function(...){
shiny_freesearcheR(...)
}

View file

@ -265,7 +265,7 @@ modal_update_factor <- function(id,
#'
#' @importFrom shinyWidgets WinBox wbOptions wbControls
#' @importFrom htmltools tagList
#' @rdname create-column
#' @rdname update-factor
winbox_update_factor <- function(id,
title = i18n("Update levels of a factor"),
options = shinyWidgets::wbOptions(),