mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2025-09-12 18:09:39 +02:00
Compare commits
No commits in common. "1b425b5a946eaa0a50c27938b49b504ad49428e6" and "68c93d94e4af7318831867a57681a8aac22cb101" have entirely different histories.
1b425b5a94
...
68c93d94e4
50 changed files with 452 additions and 1067 deletions
|
@ -1,6 +1,6 @@
|
|||
^renv$
|
||||
^renv\.lock$
|
||||
^FreesearchR\.Rproj$
|
||||
^freesearcheR\.Rproj$
|
||||
^\.Rproj\.user$
|
||||
^LICENSE\.md$
|
||||
^dev$
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Package: FreesearchR
|
||||
Package: freesearcheR
|
||||
Title: Browser Based Data Analysis
|
||||
Version: 25.3.2
|
||||
Authors@R:
|
||||
|
@ -80,6 +80,6 @@ Suggests:
|
|||
rsconnect,
|
||||
knitr,
|
||||
rmarkdown
|
||||
URL: https://github.com/agdamsbo/FreesearchR, https://agdamsbo.github.io/FreesearchR/
|
||||
BugReports: https://github.com/agdamsbo/FreesearchR/issues
|
||||
URL: https://github.com/agdamsbo/freesearcheR, https://agdamsbo.github.io/freesearcheR/
|
||||
BugReports: https://github.com/agdamsbo/freesearcheR/issues
|
||||
VignetteBuilder: knitr
|
||||
|
|
|
@ -5,8 +5,6 @@ S3method(plot,tbl_regression)
|
|||
export(add_class_icon)
|
||||
export(add_sparkline)
|
||||
export(all_but)
|
||||
export(allign_axes)
|
||||
export(append_list)
|
||||
export(argsstring2list)
|
||||
export(baseline_table)
|
||||
export(clean_date)
|
||||
|
@ -50,8 +48,7 @@ export(is_consecutive)
|
|||
export(is_datetime)
|
||||
export(is_valid_redcap_url)
|
||||
export(is_valid_token)
|
||||
export(launch_FreesearchR)
|
||||
export(limit_log)
|
||||
export(launch_freesearcheR)
|
||||
export(line_break)
|
||||
export(m_datafileUI)
|
||||
export(m_redcap_readServer)
|
||||
|
@ -84,11 +81,11 @@ export(remove_na_attr)
|
|||
export(repeated_instruments)
|
||||
export(sankey_ready)
|
||||
export(selectInputIcon)
|
||||
export(shiny_freesearcheR)
|
||||
export(specify_qmd_format)
|
||||
export(subset_types)
|
||||
export(supported_functions)
|
||||
export(supported_plots)
|
||||
export(symmetrical_scale_x_log10)
|
||||
export(tbl_merge)
|
||||
export(update_factor_server)
|
||||
export(update_factor_ui)
|
||||
|
@ -99,7 +96,6 @@ export(vertical_stacked_bars)
|
|||
export(wide2long)
|
||||
export(winbox_cut_variable)
|
||||
export(winbox_update_factor)
|
||||
export(wrap_plot_list)
|
||||
export(write_quarto)
|
||||
importFrom(classInt,classIntervals)
|
||||
importFrom(data.table,as.data.table)
|
||||
|
|
6
NEWS.md
6
NEWS.md
|
@ -1,12 +1,12 @@
|
|||
# FreesearchR 25.3.2
|
||||
# freesearcheR 25.3.2
|
||||
|
||||
Focus is on polish and improved ui/ux.
|
||||
|
||||
Updating name (will be FreesearchR), with renamed repository and some graphics are comng. This may introduce some breaking chances for others calling or installing the package. No future changes are planned. A complete transition is planned before attending and presenting a poster at the European Stroke Organisation Conference 2025 in May.
|
||||
First steps towards an updated name (will be FreesearchR), with renamed repository. Also, the repo will move to an organisation (named FreesearchR).
|
||||
|
||||
Testing file upload conducted and improved.
|
||||
|
||||
Working on improving code export.
|
||||
Working on omproving code export.
|
||||
|
||||
# freesearcheR 25.3.1
|
||||
|
||||
|
|
2
QA.md
2
QA.md
|
@ -1,6 +1,6 @@
|
|||
# Questions and answers
|
||||
|
||||
A complete instructions set [is also available](https://agdamsbo.github.io/FreesearchR/articles/FreesearchR.html), but below are a collection of questions and answers about the project and use of the ***FreesearchR*** app.
|
||||
A complete instructions set is not available, but below are a collection of questions and answers about the project and use of the app.
|
||||
|
||||
## Are you keeping the uploaded data?
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
app_version <- function()'250319_1327'
|
||||
app_version <- function()'250318_0819'
|
||||
|
|
|
@ -102,16 +102,13 @@ library(shiny)
|
|||
#' f <- d_t |> cut(2)
|
||||
#' readr::parse_time(c("01:00:20", "03:00:20", "01:20:20", "03:02:20", NA)) |> cut(breaks = lubridate::as_datetime(c(hms::as_hms(levels(f)), hms::as_hms(max(d_t, na.rm = TRUE) + 1))), right = FALSE)
|
||||
cut.hms <- function(x, breaks, ...) {
|
||||
## as_hms keeps returning warnings on tz(); ignored
|
||||
suppressWarnings({
|
||||
if (hms::is_hms(breaks)) {
|
||||
breaks <- lubridate::as_datetime(breaks)
|
||||
breaks <- lubridate::as_datetime(breaks, tz = "UTC")
|
||||
}
|
||||
x <- lubridate::as_datetime(x)
|
||||
x <- lubridate::as_datetime(x, tz = "UTC")
|
||||
out <- cut.POSIXt(x, breaks = breaks, ...)
|
||||
attr(out, which = "brks") <- hms::as_hms(lubridate::as_datetime(attr(out, which = "brks")))
|
||||
attr(out, which = "levels") <- as.character(hms::as_hms(lubridate::as_datetime(attr(out, which = "levels"))))
|
||||
})
|
||||
out
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,27 @@ data_import_server <- function(id) {
|
|||
id = ns("file_import"),
|
||||
show_data_in = "popup",
|
||||
trigger_return = "change",
|
||||
return_class = "data.frame"
|
||||
return_class = "data.frame",
|
||||
read_fns = list(
|
||||
ods = import_ods,
|
||||
dta = function(file) {
|
||||
haven::read_dta(
|
||||
file = file,
|
||||
.name_repair = "unique_quiet"
|
||||
)
|
||||
},
|
||||
csv = import_delim,
|
||||
tsv = import_delim,
|
||||
txt = import_delim,
|
||||
xls = import_xls,
|
||||
xlsx = import_xls,
|
||||
rds = function(file) {
|
||||
readr::read_rds(
|
||||
file = file,
|
||||
name_repair = "unique_quiet"
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
shiny::observeEvent(data_file$data(), {
|
||||
|
|
178
R/data_plots.R
178
R/data_plots.R
|
@ -112,99 +112,6 @@ data_visuals_server <- function(id,
|
|||
plot = NULL
|
||||
)
|
||||
|
||||
# ## --- New attempt
|
||||
#
|
||||
# rv$plot.params <- shiny::reactive({
|
||||
# get_plot_options(input$type) |> purrr::pluck(1)
|
||||
# })
|
||||
#
|
||||
# c(output,
|
||||
# list(shiny::renderUI({
|
||||
# columnSelectInput(
|
||||
# inputId = ns("primary"),
|
||||
# data = data,
|
||||
# placeholder = "Select variable",
|
||||
# label = "Response variable",
|
||||
# multiple = FALSE
|
||||
# )
|
||||
# }),
|
||||
# shiny::renderUI({
|
||||
# shiny::req(input$primary)
|
||||
# # browser()
|
||||
#
|
||||
# if (!input$primary %in% names(data())) {
|
||||
# plot_data <- data()[1]
|
||||
# } else {
|
||||
# plot_data <- data()[input$primary]
|
||||
# }
|
||||
#
|
||||
# plots <- possible_plots(
|
||||
# data = plot_data
|
||||
# )
|
||||
#
|
||||
# plots_named <- get_plot_options(plots) |>
|
||||
# lapply(\(.x){
|
||||
# stats::setNames(.x$descr, .x$note)
|
||||
# })
|
||||
#
|
||||
# vectorSelectInput(
|
||||
# inputId = ns("type"),
|
||||
# selected = NULL,
|
||||
# label = shiny::h4("Plot type"),
|
||||
# choices = Reduce(c, plots_named),
|
||||
# multiple = FALSE
|
||||
# )
|
||||
# }),
|
||||
# shiny::renderUI({
|
||||
# shiny::req(input$type)
|
||||
#
|
||||
# cols <- c(
|
||||
# rv$plot.params()[["secondary.extra"]],
|
||||
# all_but(
|
||||
# colnames(subset_types(
|
||||
# data(),
|
||||
# rv$plot.params()[["secondary.type"]]
|
||||
# )),
|
||||
# input$primary
|
||||
# )
|
||||
# )
|
||||
#
|
||||
# columnSelectInput(
|
||||
# inputId = ns("secondary"),
|
||||
# data = data,
|
||||
# selected = cols[1],
|
||||
# placeholder = "Please select",
|
||||
# label = if (isTRUE(rv$plot.params()[["secondary.multi"]])) "Additional variables" else "Secondary variable",
|
||||
# multiple = rv$plot.params()[["secondary.multi"]],
|
||||
# maxItems = rv$plot.params()[["secondary.max"]],
|
||||
# col_subset = cols,
|
||||
# none_label = "No variable"
|
||||
# )
|
||||
# }),
|
||||
# shiny::renderUI({
|
||||
# shiny::req(input$type)
|
||||
# columnSelectInput(
|
||||
# inputId = ns("tertiary"),
|
||||
# data = data,
|
||||
# placeholder = "Please select",
|
||||
# label = "Grouping variable",
|
||||
# multiple = FALSE,
|
||||
# col_subset = c(
|
||||
# "none",
|
||||
# all_but(
|
||||
# colnames(subset_types(
|
||||
# data(),
|
||||
# rv$plot.params()[["tertiary.type"]]
|
||||
# )),
|
||||
# input$primary,
|
||||
# input$secondary
|
||||
# )
|
||||
# ),
|
||||
# none_label = "No stratification"
|
||||
# )
|
||||
# })
|
||||
# )|> setNames(c("primary","type","secondary","tertiary")),keep.null = TRUE)
|
||||
|
||||
output$primary <- shiny::renderUI({
|
||||
columnSelectInput(
|
||||
inputId = ns("primary"),
|
||||
|
@ -457,16 +364,6 @@ supported_plots <- function() {
|
|||
tertiary.type = c("dichotomous", "ordinal"),
|
||||
secondary.extra = NULL
|
||||
),
|
||||
plot_box = list(
|
||||
fun = "plot_box",
|
||||
descr = "Box plot",
|
||||
note = "A classic way to plot data distribution by groups",
|
||||
primary.type = c("continuous", "dichotomous", "ordinal"),
|
||||
secondary.type = c("dichotomous", "ordinal"),
|
||||
secondary.multi = FALSE,
|
||||
tertiary.type = c("dichotomous", "ordinal"),
|
||||
secondary.extra = "none"
|
||||
),
|
||||
plot_euler = list(
|
||||
fun = "plot_euler",
|
||||
descr = "Euler diagram",
|
||||
|
@ -638,49 +535,18 @@ line_break <- function(data, lineLength = 20, fixed = FALSE) {
|
|||
}
|
||||
|
||||
|
||||
#' Wrapping
|
||||
#'
|
||||
#' @param data list of ggplot2 objects
|
||||
#' @param tag_levels passed to patchwork::plot_annotation if given. Default is NULL
|
||||
#'
|
||||
#' @returns list of ggplot2 objects
|
||||
#' @export
|
||||
#'
|
||||
wrap_plot_list <- function(data, tag_levels = NULL) {
|
||||
if (ggplot2::is.ggplot(data[[1]])) {
|
||||
if (length(data) > 1) {
|
||||
out <- data |>
|
||||
(\(.x){
|
||||
if (rlang::is_named(.x)) {
|
||||
purrr::imap(.x, \(.y, .i){
|
||||
.y + ggplot2::ggtitle(.i)
|
||||
})
|
||||
} else {
|
||||
.x
|
||||
}
|
||||
})() |>
|
||||
allign_axes() |>
|
||||
patchwork::wrap_plots(guides = "collect", axes = "collect", axis_titles = "collect")
|
||||
if (!is.null(tag_levels)) {
|
||||
out <- out + patchwork::plot_annotation(tag_levels = tag_levels)
|
||||
}
|
||||
} else {
|
||||
out <- data
|
||||
}
|
||||
wrap_plot_list <- function(data) {
|
||||
if (length(data) > 1) {
|
||||
out <- data |>
|
||||
allign_axes() |>
|
||||
patchwork::wrap_plots(guides = "collect", axes = "collect", axis_titles = "collect")
|
||||
} else {
|
||||
cli::cli_abort("Can only wrap lists of {.cls ggplot} objects")
|
||||
out <- data
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
|
||||
#' Alligns axes between plots
|
||||
#'
|
||||
#' @param ... ggplot2 objects or list of ggplot2 objects
|
||||
#'
|
||||
#' @returns list of ggplot2 objects
|
||||
#' @export
|
||||
#'
|
||||
allign_axes <- function(...) {
|
||||
# https://stackoverflow.com/questions/62818776/get-axis-limits-from-ggplot-object
|
||||
# https://github.com/thomasp85/patchwork/blob/main/R/plot_multipage.R#L150
|
||||
|
@ -692,30 +558,16 @@ allign_axes <- function(...) {
|
|||
cli::cli_abort("Can only align {.cls ggplot} objects or a list of them")
|
||||
}
|
||||
|
||||
yr <- clean_common_axis(p, "y")
|
||||
# browser()
|
||||
yr <- purrr::map(p, ~ ggplot2::layer_scales(.x)$y$get_limits()) |>
|
||||
unlist() |>
|
||||
range() |>
|
||||
unique()
|
||||
|
||||
xr <- clean_common_axis(p, "x")
|
||||
xr <- purrr::map(p, ~ ggplot2::layer_scales(.x)$x$get_limits()) |>
|
||||
unlist() |>
|
||||
range() |>
|
||||
unique()
|
||||
|
||||
p |> purrr::map(~ .x + ggplot2::xlim(xr) + ggplot2::ylim(yr))
|
||||
}
|
||||
|
||||
#' Extract and clean axis ranges
|
||||
#'
|
||||
#' @param p plot
|
||||
#' @param axis axis. x or y.
|
||||
#'
|
||||
#' @returns vector
|
||||
#' @export
|
||||
#'
|
||||
clean_common_axis <- function(p, axis) {
|
||||
purrr::map(p, ~ ggplot2::layer_scales(.x)[[axis]]$get_limits()) |>
|
||||
unlist() |>
|
||||
(\(.x){
|
||||
if (is.numeric(.x)) {
|
||||
range(.x)
|
||||
} else {
|
||||
.x
|
||||
}
|
||||
})() |>
|
||||
unique()
|
||||
}
|
||||
|
|
|
@ -215,9 +215,7 @@ default_parsing <- function(data) {
|
|||
out <- data |>
|
||||
REDCapCAST::parse_data() |>
|
||||
REDCapCAST::as_factor() |>
|
||||
REDCapCAST::numchar2fct(numeric.threshold = 8,character.throshold = 10) |>
|
||||
REDCapCAST::as_logical() |>
|
||||
REDCapCAST::fct_drop()
|
||||
REDCapCAST::numchar2fct()
|
||||
|
||||
purrr::map2(out,name_labels,\(.x,.l){
|
||||
if (!(is.na(.l) | .l=="")) {
|
||||
|
@ -277,7 +275,6 @@ remove_empty_cols <- function(data,cutoff=.7){
|
|||
#' @param index index name
|
||||
#'
|
||||
#' @returns list
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' ls_d <- list(test=c(1:20))
|
||||
|
|
|
@ -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 = "FreesearchR")
|
||||
code <- rlang::call2(read_fns[[extension]], !!!modifyList(parameters, list(file = input$file$name)), .ns = "freesearcheR")
|
||||
|
||||
if (inherits(imported, "try-error")) {
|
||||
imported <- try(rlang::exec(rio::import, !!!parameters[1]), silent = TRUE)
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
#' 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))
|
||||
}
|
80
R/plot_box.R
80
R/plot_box.R
|
@ -1,80 +0,0 @@
|
|||
#' Beautiful box plot(s)
|
||||
#'
|
||||
#' @returns ggplot2 object
|
||||
#' @export
|
||||
#'
|
||||
#' @name data-plots
|
||||
#'
|
||||
#' @examples
|
||||
#' mtcars |> plot_box(x = "mpg", y = "cyl", z = "gear")
|
||||
#' mtcars |>
|
||||
#' default_parsing() |>
|
||||
#' plot_box(x = "mpg", y = "cyl", z = "gear")
|
||||
plot_box <- function(data, x, y, z = NULL) {
|
||||
if (!is.null(z)) {
|
||||
ds <- split(data, data[z])
|
||||
} else {
|
||||
ds <- list(data)
|
||||
}
|
||||
|
||||
out <- lapply(ds, \(.ds){
|
||||
plot_box_single(
|
||||
data = .ds,
|
||||
x = x,
|
||||
y = y
|
||||
)
|
||||
})
|
||||
|
||||
wrap_plot_list(out)
|
||||
# patchwork::wrap_plots(out,guides = "collect")
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#' Create nice box-plots
|
||||
#'
|
||||
#' @name data-plots
|
||||
#'
|
||||
#' @returns
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' mtcars |> plot_box_single("mpg","cyl")
|
||||
plot_box_single <- function(data, x, y=NULL, seed = 2103) {
|
||||
set.seed(seed)
|
||||
|
||||
if (is.null(y)) {
|
||||
y <- "All"
|
||||
data[[y]] <- y
|
||||
}
|
||||
|
||||
discrete <- !outcome_type(data[[y]]) %in% "continuous"
|
||||
|
||||
data |>
|
||||
ggplot2::ggplot(ggplot2::aes(x = !!dplyr::sym(x), y = !!dplyr::sym(y), fill = !!dplyr::sym(y), group = !!dplyr::sym(y))) +
|
||||
ggplot2::geom_boxplot(linewidth = 1.8, outliers = FALSE) +
|
||||
## THis could be optional in future
|
||||
ggplot2::geom_jitter(color = "black", size = 2, alpha = 0.9) +
|
||||
ggplot2::coord_flip() +
|
||||
viridis::scale_fill_viridis(discrete = discrete, option = "D") +
|
||||
# ggplot2::theme_void() +
|
||||
ggplot2::theme_bw(base_size = 24) +
|
||||
ggplot2::theme(
|
||||
legend.position = "none",
|
||||
# panel.grid.major = element_blank(),
|
||||
# panel.grid.minor = element_blank(),
|
||||
# axis.text.y = element_blank(),
|
||||
# axis.title.y = element_blank(),
|
||||
# text = ggplot2::element_text(size = 20),
|
||||
# axis.text = ggplot2::element_blank(),
|
||||
# plot.title = element_blank(),
|
||||
panel.background = ggplot2::element_rect(fill = "white"),
|
||||
plot.background = ggplot2::element_rect(fill = "white"),
|
||||
panel.border = ggplot2::element_blank(),
|
||||
panel.grid.major = ggplot2::element_blank(),
|
||||
panel.grid.minor = ggplot2::element_blank(),
|
||||
axis.line = ggplot2::element_line(colour = "black"),
|
||||
axis.ticks = ggplot2::element_line(colour = "black")
|
||||
)
|
||||
}
|
|
@ -78,6 +78,9 @@ ggeulerr <- function(
|
|||
#' mtcars |> plot_euler("vs", "am", seed = 1)
|
||||
plot_euler <- function(data, x, y, z = NULL, seed = 2103) {
|
||||
set.seed(seed = seed)
|
||||
|
||||
# data <- data[c(...,z)]
|
||||
|
||||
if (!is.null(z)) {
|
||||
ds <- split(data, data[z])
|
||||
} else {
|
||||
|
@ -90,7 +93,6 @@ plot_euler <- function(data, x, y, z = NULL, seed = 2103) {
|
|||
plot_euler_single()
|
||||
})
|
||||
|
||||
# names(out)
|
||||
wrap_plot_list(out)
|
||||
# patchwork::wrap_plots(out, guides = "collect")
|
||||
}
|
||||
|
@ -114,7 +116,7 @@ plot_euler_single <- function(data) {
|
|||
ggeulerr(shape = "circle") +
|
||||
ggplot2::theme_void() +
|
||||
ggplot2::theme(
|
||||
legend.position = "none",
|
||||
legend.position = "right",
|
||||
# panel.grid.major = element_blank(),
|
||||
# panel.grid.minor = element_blank(),
|
||||
# axis.text.y = element_blank(),
|
||||
|
|
|
@ -15,16 +15,15 @@
|
|||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' mod <- lm(mpg ~ ., default_parsing(mtcars))
|
||||
#' mod <- lm(mpg ~ ., mtcars)
|
||||
#' p <- mod |>
|
||||
#' gtsummary::tbl_regression() |>
|
||||
#' plot(colour = "variable")
|
||||
#' }
|
||||
#'
|
||||
plot.tbl_regression <- function(x,
|
||||
plot_ref = TRUE,
|
||||
remove_header_rows = TRUE,
|
||||
remove_reference_rows = FALSE,
|
||||
# remove_header_rows = TRUE,
|
||||
# remove_reference_rows = FALSE,
|
||||
...) {
|
||||
# check_dots_empty()
|
||||
gtsummary:::check_pkg_installed("ggstats")
|
||||
|
@ -33,31 +32,33 @@ 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)
|
||||
# }
|
||||
|
||||
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)
|
||||
}
|
||||
# browser()
|
||||
|
||||
# Removes redundant label
|
||||
df_coefs$label[df_coefs$row_type == "label"] <- ""
|
||||
|
||||
# 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}
|
||||
|
||||
p <- df_coefs |>
|
||||
df_coefs %>%
|
||||
ggstats::ggcoef_plot(exponentiate = x$inputs$exponentiate, ...)
|
||||
|
||||
if (x$inputs$exponentiate){
|
||||
p <- symmetrical_scale_x_log10(p)
|
||||
}
|
||||
p
|
||||
}
|
||||
|
||||
|
||||
# default_parsing(mtcars) |> lapply(class)
|
||||
#
|
||||
# purrr::imap(mtcars,\(.x,.i){
|
||||
# if (.i %in% c("vs","am","gear","carb")){
|
||||
# as.factor(.x)
|
||||
# } else .x
|
||||
# }) |> dplyr::bind_cols()
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
#' Wrapper to pivot gtsummary table data to long for plotting
|
||||
#'
|
||||
#' @param list a custom regression models list
|
||||
|
@ -97,47 +98,3 @@ merge_long <- function(list, model.names) {
|
|||
|
||||
l_merged
|
||||
}
|
||||
|
||||
|
||||
#' Easily round log scale limits for nice plots
|
||||
#'
|
||||
#' @param data data
|
||||
#' @param fun rounding function (floor/ceiling)
|
||||
#' @param ... ignored
|
||||
#'
|
||||
#' @returns numeric vector
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' limit_log(-.1,floor)
|
||||
#' limit_log(.1,ceiling)
|
||||
#' limit_log(-2.1,ceiling)
|
||||
#' limit_log(2.1,ceiling)
|
||||
limit_log <- function(data,fun,...){
|
||||
fun(10^-floor(data)*10^data)/10^-floor(data)
|
||||
}
|
||||
|
||||
#' Ensure symmetrical plot around 1 on a logarithmic x scale for ratio plots
|
||||
#'
|
||||
#' @param plot ggplot2 plot
|
||||
#' @param breaks breaks used and mirrored
|
||||
#' @param ... ignored
|
||||
#'
|
||||
#' @returns ggplot2 object
|
||||
#' @export
|
||||
#'
|
||||
symmetrical_scale_x_log10 <- function(plot,breaks=c(1,2,3,5,10),...){
|
||||
rx <- ggplot2::layer_scales(plot)$x$get_limits()
|
||||
|
||||
x_min <- floor(10*rx[1])/10
|
||||
x_max <- ceiling(10*rx[2])/10
|
||||
|
||||
rx_min <- limit_log(rx[1],floor)
|
||||
rx_max <- limit_log(rx[2],ceiling)
|
||||
|
||||
max_abs_x <- max(abs(c(x_min,x_max)))
|
||||
|
||||
ticks <- log10(breaks)+(ceiling(max_abs_x)-1)
|
||||
|
||||
plot + ggplot2::scale_x_log10(limits=c(rx_min,rx_max),breaks=create_log_tics(10^ticks[ticks<=max_abs_x]))
|
||||
}
|
||||
|
|
|
@ -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) != "freesearchr_model"]
|
||||
#' class(x) <- class(x)[class(x) != "freesearcher_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) != "freesearchr_model"]
|
||||
class(x) <- class(x)[class(x) != "freesearcher_model"]
|
||||
|
||||
if (any(c(length(class(x)) != 1, class(x) != "lm"))) {
|
||||
if (!"exponentiate" %in% names(args.list)) {
|
||||
|
|
37
R/shiny_freesearcheR.R
Normal file
37
R/shiny_freesearcheR.R
Normal file
|
@ -0,0 +1,37 @@
|
|||
#' 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(...)
|
||||
}
|
|
@ -265,7 +265,7 @@ modal_update_factor <- function(id,
|
|||
#'
|
||||
#' @importFrom shinyWidgets WinBox wbOptions wbControls
|
||||
#' @importFrom htmltools tagList
|
||||
#' @rdname update-factor
|
||||
#' @rdname create-column
|
||||
winbox_update_factor <- function(id,
|
||||
title = i18n("Update levels of a factor"),
|
||||
options = shinyWidgets::wbOptions(),
|
||||
|
|
22
README.md
22
README.md
|
@ -1,35 +1,35 @@
|
|||
# FreesearchR
|
||||
# freesearcheR
|
||||
|
||||
<!-- badges: start -->
|
||||
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
|
||||
[](https://github.com/agdamsbo/freesearcheR/actions/workflows/rhub.yaml)
|
||||
[](https://doi.org/10.5281/zenodo.14527429)
|
||||
[](https://github.com/agdamsbo/FreesearchR/actions/workflows/rhub.yaml)
|
||||
[](https://agdamsbo.shinyapps.io/freesearcheR/)
|
||||
[](https://agdamsbo.shinyapps.io/freesearcheR/)
|
||||
<!-- badges: end -->
|
||||
|
||||
This package is the backbone of the ***FreesearchR***, a free and open-source browser based data exploration and analysis tool for clinicians and researchers with publication ready output.
|
||||
This package is the backbone of the ***freesearcheR***, a free and open-source browser based data exploration and analysis tool for clinicians and researchers with publication ready output.
|
||||
|
||||
This package and the ***FreesearchR***-tool is part of a larger initiative to democratize health data analysis and remove barriers for clinicians to engage in health research.
|
||||
This package and the ***freesearcheR***-tool is part of a larger initiative to democratize health data analysis and remove barriers for clinicians to engage in health research.
|
||||
|
||||
the ***FreesearchR***-tool is online and accessible here: [link to the app freely hosted on shinyapps.io](https://agdamsbo.shinyapps.io/FreesearchR/). All feedback is welcome and can be shared as a GitHub issue.
|
||||
the ***freesearcheR***-tool is online and accessible here: [link to the app freely hosted on shinyapps.io](https://agdamsbo.shinyapps.io/freesearcheR/). All feedback is welcome and can be shared as a GitHub issue.
|
||||
|
||||
Initiatives for funding continued development of the tool and surrounding initiatives is ongoing.
|
||||
|
||||
|
||||
## Install locally
|
||||
|
||||
The ***FreesearchR***-tool can also be launched locally. Any data.frame available in the global environment will be accessible from the interface.
|
||||
The ***freesearcheR***-tool can also be launched locally. Any data.frame available in the global environment will be accessible from the interface.
|
||||
|
||||
```
|
||||
require("devtools")
|
||||
devtools::install_github("agdamsbo/FreesearchR")
|
||||
library(FreesearchR)
|
||||
devtools::install_github("agdamsbo/freesearcheR")
|
||||
library(freesearcheR)
|
||||
# By loading mtcars to the environment, it will be available
|
||||
# in the interface like any other data.frame
|
||||
data(mtcars)
|
||||
launch_FreesearchR()
|
||||
shiny_freesearcheR()
|
||||
```
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
Please note that the ***FreesearchR*** project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
|
||||
Please note that the freesearcheR project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
url: https://agdamsbo.github.io/FreesearchR/
|
||||
url: https://agdamsbo.github.io/freesearcheR/
|
||||
template:
|
||||
bslib:
|
||||
version: 5
|
||||
|
|
|
@ -20,4 +20,4 @@ LineEndingConversion: Posix
|
|||
BuildType: Package
|
||||
PackageUseDevtools: Yes
|
||||
PackageInstallArgs: --no-multiarch --with-keep.source
|
||||
PackageRoxygenize: rd,collate,namespace,vignette
|
||||
PackageRoxygenize: rd,collate,namespace
|
|
@ -1,11 +0,0 @@
|
|||
# Basic visualisations
|
||||
|
||||
The goal of ***FreesearchR*** is to keep things simple. Visuals can get very complicated. We provide a selection of plots, that helps visualise typical clinical and will be enough for most use cases, and for publishing to most journals.
|
||||
|
||||
If you want to go further, have a look at these sites with suggestions and sample code for data plotting:
|
||||
|
||||
- [*R* Charts](https://r-charts.com/): Extensive gallery with great plots
|
||||
|
||||
- [*R* Graph gallery](https://r-graph-gallery.com/): Another gallery with great graphs
|
||||
|
||||
- [graphics principles](https://graphicsprinciples.github.io/): Easy to follow recommendations for clear visuals.
|
|
@ -1,24 +0,0 @@
|
|||
|
||||
@book{andreasgammelgaarddamsbo2025,
|
||||
title = {agdamsbo/freesearcheR: freesearcheR 25.3.1},
|
||||
author = {Andreas Gammelgaard Damsbo, },
|
||||
year = {2025},
|
||||
month = {03},
|
||||
date = {2025-03-06},
|
||||
publisher = {Zenodo},
|
||||
doi = {10.5281/ZENODO.14527429},
|
||||
url = {https://zenodo.org/doi/10.5281/zenodo.14527429}
|
||||
}
|
||||
|
||||
@article{Aam2020,
|
||||
title = {Post-stroke Cognitive Impairment{\textemdash}Impact of Follow-Up Time and Stroke Subtype on Severity and Cognitive Profile: The Nor-COAST Study},
|
||||
author = {Aam, Stina and Einstad, Marte Stine and Munthe-Kaas, Ragnhild and Lydersen, Stian and Ihle-Hansen, Hege and Knapskog, Anne Brita and {Ellekjær}, Hanne and Seljeseth, Yngve and Saltvedt, Ingvild},
|
||||
year = {2020},
|
||||
date = {2020},
|
||||
journal = {Frontiers in Neurology},
|
||||
pages = {1--10},
|
||||
volume = {11},
|
||||
number = {July},
|
||||
doi = {10.3389/fneur.2020.00699},
|
||||
note = {Citation Key: Aam2020}
|
||||
}
|
|
@ -1,20 +1,20 @@
|
|||
|
||||
|
||||
########
|
||||
#### Current file: /Users/au301842/FreesearchR/inst/apps/FreesearchR/functions.R
|
||||
#### Current file: /Users/au301842/freesearcheR/inst/apps/freesearcheR/functions.R
|
||||
########
|
||||
|
||||
|
||||
|
||||
########
|
||||
#### Current file: R//app_version.R
|
||||
#### Current file: R//app_version.R
|
||||
########
|
||||
|
||||
app_version <- function()'250319_1327'
|
||||
app_version <- function()'250318_0819'
|
||||
|
||||
|
||||
########
|
||||
#### Current file: R//baseline_table.R
|
||||
#### Current file: R//baseline_table.R
|
||||
########
|
||||
|
||||
#' Print a flexible baseline characteristics table
|
||||
|
@ -42,7 +42,7 @@ baseline_table <- function(data, fun.args = NULL, fun = gtsummary::tbl_summary,
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//contrast_text.R
|
||||
#### Current file: R//contrast_text.R
|
||||
########
|
||||
|
||||
#' @title Contrast Text Color
|
||||
|
@ -99,7 +99,7 @@ contrast_text <- function(background,
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//correlations-module.R
|
||||
#### Current file: R//correlations-module.R
|
||||
########
|
||||
|
||||
#' Data correlations evaluation module
|
||||
|
@ -260,7 +260,7 @@ cor_demo_app()
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//custom_SelectInput.R
|
||||
#### Current file: R//custom_SelectInput.R
|
||||
########
|
||||
|
||||
#' A selectizeInput customized for data frames with column labels
|
||||
|
@ -447,7 +447,7 @@ vectorSelectInput <- function(inputId,
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//cut-variable-dates.R
|
||||
#### Current file: R//cut-variable-dates.R
|
||||
########
|
||||
|
||||
library(datamods)
|
||||
|
@ -554,16 +554,13 @@ library(shiny)
|
|||
#' f <- d_t |> cut(2)
|
||||
#' readr::parse_time(c("01:00:20", "03:00:20", "01:20:20", "03:02:20", NA)) |> cut(breaks = lubridate::as_datetime(c(hms::as_hms(levels(f)), hms::as_hms(max(d_t, na.rm = TRUE) + 1))), right = FALSE)
|
||||
cut.hms <- function(x, breaks, ...) {
|
||||
## as_hms keeps returning warnings on tz(); ignored
|
||||
suppressWarnings({
|
||||
if (hms::is_hms(breaks)) {
|
||||
breaks <- lubridate::as_datetime(breaks)
|
||||
breaks <- lubridate::as_datetime(breaks, tz = "UTC")
|
||||
}
|
||||
x <- lubridate::as_datetime(x)
|
||||
x <- lubridate::as_datetime(x, tz = "UTC")
|
||||
out <- cut.POSIXt(x, breaks = breaks, ...)
|
||||
attr(out, which = "brks") <- hms::as_hms(lubridate::as_datetime(attr(out, which = "brks")))
|
||||
attr(out, which = "levels") <- as.character(hms::as_hms(lubridate::as_datetime(attr(out, which = "levels"))))
|
||||
})
|
||||
out
|
||||
}
|
||||
|
||||
|
@ -1092,7 +1089,7 @@ plot_histogram <- function(data, column, bins = 30, breaks = NULL, color = "#112
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//data_plots.R
|
||||
#### Current file: R//data_plots.R
|
||||
########
|
||||
|
||||
# source(here::here("functions.R"))
|
||||
|
@ -1209,99 +1206,6 @@ data_visuals_server <- function(id,
|
|||
plot = NULL
|
||||
)
|
||||
|
||||
# ## --- New attempt
|
||||
#
|
||||
# rv$plot.params <- shiny::reactive({
|
||||
# get_plot_options(input$type) |> purrr::pluck(1)
|
||||
# })
|
||||
#
|
||||
# c(output,
|
||||
# list(shiny::renderUI({
|
||||
# columnSelectInput(
|
||||
# inputId = ns("primary"),
|
||||
# data = data,
|
||||
# placeholder = "Select variable",
|
||||
# label = "Response variable",
|
||||
# multiple = FALSE
|
||||
# )
|
||||
# }),
|
||||
# shiny::renderUI({
|
||||
# shiny::req(input$primary)
|
||||
# # browser()
|
||||
#
|
||||
# if (!input$primary %in% names(data())) {
|
||||
# plot_data <- data()[1]
|
||||
# } else {
|
||||
# plot_data <- data()[input$primary]
|
||||
# }
|
||||
#
|
||||
# plots <- possible_plots(
|
||||
# data = plot_data
|
||||
# )
|
||||
#
|
||||
# plots_named <- get_plot_options(plots) |>
|
||||
# lapply(\(.x){
|
||||
# stats::setNames(.x$descr, .x$note)
|
||||
# })
|
||||
#
|
||||
# vectorSelectInput(
|
||||
# inputId = ns("type"),
|
||||
# selected = NULL,
|
||||
# label = shiny::h4("Plot type"),
|
||||
# choices = Reduce(c, plots_named),
|
||||
# multiple = FALSE
|
||||
# )
|
||||
# }),
|
||||
# shiny::renderUI({
|
||||
# shiny::req(input$type)
|
||||
#
|
||||
# cols <- c(
|
||||
# rv$plot.params()[["secondary.extra"]],
|
||||
# all_but(
|
||||
# colnames(subset_types(
|
||||
# data(),
|
||||
# rv$plot.params()[["secondary.type"]]
|
||||
# )),
|
||||
# input$primary
|
||||
# )
|
||||
# )
|
||||
#
|
||||
# columnSelectInput(
|
||||
# inputId = ns("secondary"),
|
||||
# data = data,
|
||||
# selected = cols[1],
|
||||
# placeholder = "Please select",
|
||||
# label = if (isTRUE(rv$plot.params()[["secondary.multi"]])) "Additional variables" else "Secondary variable",
|
||||
# multiple = rv$plot.params()[["secondary.multi"]],
|
||||
# maxItems = rv$plot.params()[["secondary.max"]],
|
||||
# col_subset = cols,
|
||||
# none_label = "No variable"
|
||||
# )
|
||||
# }),
|
||||
# shiny::renderUI({
|
||||
# shiny::req(input$type)
|
||||
# columnSelectInput(
|
||||
# inputId = ns("tertiary"),
|
||||
# data = data,
|
||||
# placeholder = "Please select",
|
||||
# label = "Grouping variable",
|
||||
# multiple = FALSE,
|
||||
# col_subset = c(
|
||||
# "none",
|
||||
# all_but(
|
||||
# colnames(subset_types(
|
||||
# data(),
|
||||
# rv$plot.params()[["tertiary.type"]]
|
||||
# )),
|
||||
# input$primary,
|
||||
# input$secondary
|
||||
# )
|
||||
# ),
|
||||
# none_label = "No stratification"
|
||||
# )
|
||||
# })
|
||||
# )|> setNames(c("primary","type","secondary","tertiary")),keep.null = TRUE)
|
||||
|
||||
output$primary <- shiny::renderUI({
|
||||
columnSelectInput(
|
||||
inputId = ns("primary"),
|
||||
|
@ -1554,16 +1458,6 @@ supported_plots <- function() {
|
|||
tertiary.type = c("dichotomous", "ordinal"),
|
||||
secondary.extra = NULL
|
||||
),
|
||||
plot_box = list(
|
||||
fun = "plot_box",
|
||||
descr = "Box plot",
|
||||
note = "A classic way to plot data distribution by groups",
|
||||
primary.type = c("continuous", "dichotomous", "ordinal"),
|
||||
secondary.type = c("dichotomous", "ordinal"),
|
||||
secondary.multi = FALSE,
|
||||
tertiary.type = c("dichotomous", "ordinal"),
|
||||
secondary.extra = "none"
|
||||
),
|
||||
plot_euler = list(
|
||||
fun = "plot_euler",
|
||||
descr = "Euler diagram",
|
||||
|
@ -1735,49 +1629,18 @@ line_break <- function(data, lineLength = 20, fixed = FALSE) {
|
|||
}
|
||||
|
||||
|
||||
#' Wrapping
|
||||
#'
|
||||
#' @param data list of ggplot2 objects
|
||||
#' @param tag_levels passed to patchwork::plot_annotation if given. Default is NULL
|
||||
#'
|
||||
#' @returns list of ggplot2 objects
|
||||
#' @export
|
||||
#'
|
||||
wrap_plot_list <- function(data, tag_levels = NULL) {
|
||||
if (ggplot2::is.ggplot(data[[1]])) {
|
||||
if (length(data) > 1) {
|
||||
out <- data |>
|
||||
(\(.x){
|
||||
if (rlang::is_named(.x)) {
|
||||
purrr::imap(.x, \(.y, .i){
|
||||
.y + ggplot2::ggtitle(.i)
|
||||
})
|
||||
} else {
|
||||
.x
|
||||
}
|
||||
})() |>
|
||||
allign_axes() |>
|
||||
patchwork::wrap_plots(guides = "collect", axes = "collect", axis_titles = "collect")
|
||||
if (!is.null(tag_levels)) {
|
||||
out <- out + patchwork::plot_annotation(tag_levels = tag_levels)
|
||||
}
|
||||
} else {
|
||||
out <- data
|
||||
}
|
||||
wrap_plot_list <- function(data) {
|
||||
if (length(data) > 1) {
|
||||
out <- data |>
|
||||
allign_axes() |>
|
||||
patchwork::wrap_plots(guides = "collect", axes = "collect", axis_titles = "collect")
|
||||
} else {
|
||||
cli::cli_abort("Can only wrap lists of {.cls ggplot} objects")
|
||||
out <- data
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
|
||||
#' Alligns axes between plots
|
||||
#'
|
||||
#' @param ... ggplot2 objects or list of ggplot2 objects
|
||||
#'
|
||||
#' @returns list of ggplot2 objects
|
||||
#' @export
|
||||
#'
|
||||
allign_axes <- function(...) {
|
||||
# https://stackoverflow.com/questions/62818776/get-axis-limits-from-ggplot-object
|
||||
# https://github.com/thomasp85/patchwork/blob/main/R/plot_multipage.R#L150
|
||||
|
@ -1789,37 +1652,23 @@ allign_axes <- function(...) {
|
|||
cli::cli_abort("Can only align {.cls ggplot} objects or a list of them")
|
||||
}
|
||||
|
||||
yr <- clean_common_axis(p, "y")
|
||||
# browser()
|
||||
yr <- purrr::map(p, ~ ggplot2::layer_scales(.x)$y$get_limits()) |>
|
||||
unlist() |>
|
||||
range() |>
|
||||
unique()
|
||||
|
||||
xr <- clean_common_axis(p, "x")
|
||||
xr <- purrr::map(p, ~ ggplot2::layer_scales(.x)$x$get_limits()) |>
|
||||
unlist() |>
|
||||
range() |>
|
||||
unique()
|
||||
|
||||
p |> purrr::map(~ .x + ggplot2::xlim(xr) + ggplot2::ylim(yr))
|
||||
}
|
||||
|
||||
#' Extract and clean axis ranges
|
||||
#'
|
||||
#' @param p plot
|
||||
#' @param axis axis. x or y.
|
||||
#'
|
||||
#' @returns vector
|
||||
#' @export
|
||||
#'
|
||||
clean_common_axis <- function(p, axis) {
|
||||
purrr::map(p, ~ ggplot2::layer_scales(.x)[[axis]]$get_limits()) |>
|
||||
unlist() |>
|
||||
(\(.x){
|
||||
if (is.numeric(.x)) {
|
||||
range(.x)
|
||||
} else {
|
||||
.x
|
||||
}
|
||||
})() |>
|
||||
unique()
|
||||
}
|
||||
|
||||
|
||||
########
|
||||
#### Current file: R//data-import.R
|
||||
#### Current file: R//data-import.R
|
||||
########
|
||||
|
||||
data_import_ui <- function(id) {
|
||||
|
@ -1883,7 +1732,27 @@ data_import_server <- function(id) {
|
|||
id = ns("file_import"),
|
||||
show_data_in = "popup",
|
||||
trigger_return = "change",
|
||||
return_class = "data.frame"
|
||||
return_class = "data.frame",
|
||||
read_fns = list(
|
||||
ods = import_ods,
|
||||
dta = function(file) {
|
||||
haven::read_dta(
|
||||
file = file,
|
||||
.name_repair = "unique_quiet"
|
||||
)
|
||||
},
|
||||
csv = import_delim,
|
||||
tsv = import_delim,
|
||||
txt = import_delim,
|
||||
xls = import_xls,
|
||||
xlsx = import_xls,
|
||||
rds = function(file) {
|
||||
readr::read_rds(
|
||||
file = file,
|
||||
name_repair = "unique_quiet"
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
shiny::observeEvent(data_file$data(), {
|
||||
|
@ -1976,7 +1845,7 @@ data_import_demo_app <- function() {
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//data-summary.R
|
||||
#### Current file: R//data-summary.R
|
||||
########
|
||||
|
||||
#' Data summary module
|
||||
|
@ -2285,7 +2154,7 @@ add_class_icon <- function(grid, column = "class") {
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//file-import-module.R
|
||||
#### Current file: R//file-import-module.R
|
||||
########
|
||||
|
||||
#' Shiny UI module to load a data file
|
||||
|
@ -2416,7 +2285,7 @@ file_app()
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//helpers.R
|
||||
#### Current file: R//helpers.R
|
||||
########
|
||||
|
||||
#' Wrapper function to get function from character vector referring to function from namespace. Passed to 'do.call()'
|
||||
|
@ -2636,9 +2505,7 @@ default_parsing <- function(data) {
|
|||
out <- data |>
|
||||
REDCapCAST::parse_data() |>
|
||||
REDCapCAST::as_factor() |>
|
||||
REDCapCAST::numchar2fct(numeric.threshold = 8,character.throshold = 10) |>
|
||||
REDCapCAST::as_logical() |>
|
||||
REDCapCAST::fct_drop()
|
||||
REDCapCAST::numchar2fct()
|
||||
|
||||
purrr::map2(out,name_labels,\(.x,.l){
|
||||
if (!(is.na(.l) | .l=="")) {
|
||||
|
@ -2698,7 +2565,6 @@ remove_empty_cols <- function(data,cutoff=.7){
|
|||
#' @param index index name
|
||||
#'
|
||||
#' @returns list
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' ls_d <- list(test=c(1:20))
|
||||
|
@ -2733,7 +2599,7 @@ missing_fraction <- function(data){
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//import-file-ext.R
|
||||
#### Current file: R//import-file-ext.R
|
||||
########
|
||||
|
||||
#' @title Import data from a file
|
||||
|
@ -2992,7 +2858,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 = "FreesearchR")
|
||||
code <- rlang::call2(read_fns[[extension]], !!!modifyList(parameters, list(file = input$file$name)), .ns = "freesearcheR")
|
||||
|
||||
if (inherits(imported, "try-error")) {
|
||||
imported <- try(rlang::exec(rio::import, !!!parameters[1]), silent = TRUE)
|
||||
|
@ -3308,123 +3174,7 @@ import_file_demo_app <- function() {
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//launch_FreesearchR.R
|
||||
########
|
||||
|
||||
#' 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))
|
||||
}
|
||||
|
||||
|
||||
########
|
||||
#### Current file: R//plot_box.R
|
||||
########
|
||||
|
||||
#' Beautiful box plot(s)
|
||||
#'
|
||||
#' @returns ggplot2 object
|
||||
#' @export
|
||||
#'
|
||||
#' @name data-plots
|
||||
#'
|
||||
#' @examples
|
||||
#' mtcars |> plot_box(x = "mpg", y = "cyl", z = "gear")
|
||||
#' mtcars |>
|
||||
#' default_parsing() |>
|
||||
#' plot_box(x = "mpg", y = "cyl", z = "gear")
|
||||
plot_box <- function(data, x, y, z = NULL) {
|
||||
if (!is.null(z)) {
|
||||
ds <- split(data, data[z])
|
||||
} else {
|
||||
ds <- list(data)
|
||||
}
|
||||
|
||||
out <- lapply(ds, \(.ds){
|
||||
plot_box_single(
|
||||
data = .ds,
|
||||
x = x,
|
||||
y = y
|
||||
)
|
||||
})
|
||||
|
||||
wrap_plot_list(out)
|
||||
# patchwork::wrap_plots(out,guides = "collect")
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#' Create nice box-plots
|
||||
#'
|
||||
#' @name data-plots
|
||||
#'
|
||||
#' @returns
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' mtcars |> plot_box_single("mpg","cyl")
|
||||
plot_box_single <- function(data, x, y=NULL, seed = 2103) {
|
||||
set.seed(seed)
|
||||
|
||||
if (is.null(y)) {
|
||||
y <- "All"
|
||||
data[[y]] <- y
|
||||
}
|
||||
|
||||
discrete <- !outcome_type(data[[y]]) %in% "continuous"
|
||||
|
||||
data |>
|
||||
ggplot2::ggplot(ggplot2::aes(x = !!dplyr::sym(x), y = !!dplyr::sym(y), fill = !!dplyr::sym(y), group = !!dplyr::sym(y))) +
|
||||
ggplot2::geom_boxplot(linewidth = 1.8, outliers = FALSE) +
|
||||
## THis could be optional in future
|
||||
ggplot2::geom_jitter(color = "black", size = 2, alpha = 0.9) +
|
||||
ggplot2::coord_flip() +
|
||||
viridis::scale_fill_viridis(discrete = discrete, option = "D") +
|
||||
# ggplot2::theme_void() +
|
||||
ggplot2::theme_bw(base_size = 24) +
|
||||
ggplot2::theme(
|
||||
legend.position = "none",
|
||||
# panel.grid.major = element_blank(),
|
||||
# panel.grid.minor = element_blank(),
|
||||
# axis.text.y = element_blank(),
|
||||
# axis.title.y = element_blank(),
|
||||
# text = ggplot2::element_text(size = 20),
|
||||
# axis.text = ggplot2::element_blank(),
|
||||
# plot.title = element_blank(),
|
||||
panel.background = ggplot2::element_rect(fill = "white"),
|
||||
plot.background = ggplot2::element_rect(fill = "white"),
|
||||
panel.border = ggplot2::element_blank(),
|
||||
panel.grid.major = ggplot2::element_blank(),
|
||||
panel.grid.minor = ggplot2::element_blank(),
|
||||
axis.line = ggplot2::element_line(colour = "black"),
|
||||
axis.ticks = ggplot2::element_line(colour = "black")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
########
|
||||
#### Current file: R//plot_euler.R
|
||||
#### Current file: R//plot_euler.R
|
||||
########
|
||||
|
||||
#' Area proportional venn diagrams
|
||||
|
@ -3507,6 +3257,9 @@ ggeulerr <- function(
|
|||
#' mtcars |> plot_euler("vs", "am", seed = 1)
|
||||
plot_euler <- function(data, x, y, z = NULL, seed = 2103) {
|
||||
set.seed(seed = seed)
|
||||
|
||||
# data <- data[c(...,z)]
|
||||
|
||||
if (!is.null(z)) {
|
||||
ds <- split(data, data[z])
|
||||
} else {
|
||||
|
@ -3519,7 +3272,6 @@ plot_euler <- function(data, x, y, z = NULL, seed = 2103) {
|
|||
plot_euler_single()
|
||||
})
|
||||
|
||||
# names(out)
|
||||
wrap_plot_list(out)
|
||||
# patchwork::wrap_plots(out, guides = "collect")
|
||||
}
|
||||
|
@ -3543,7 +3295,7 @@ plot_euler_single <- function(data) {
|
|||
ggeulerr(shape = "circle") +
|
||||
ggplot2::theme_void() +
|
||||
ggplot2::theme(
|
||||
legend.position = "none",
|
||||
legend.position = "right",
|
||||
# panel.grid.major = element_blank(),
|
||||
# panel.grid.minor = element_blank(),
|
||||
# axis.text.y = element_blank(),
|
||||
|
@ -3559,7 +3311,7 @@ plot_euler_single <- function(data) {
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//plot_hbar.R
|
||||
#### Current file: R//plot_hbar.R
|
||||
########
|
||||
|
||||
#' Nice horizontal stacked bars (Grotta bars)
|
||||
|
@ -3660,7 +3412,7 @@ vertical_stacked_bars <- function(data,
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//plot_ridge.R
|
||||
#### Current file: R//plot_ridge.R
|
||||
########
|
||||
|
||||
#' Plot nice ridge plot
|
||||
|
@ -3694,7 +3446,7 @@ plot_ridge <- function(data, x, y, z = NULL, ...) {
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//plot_sankey.R
|
||||
#### Current file: R//plot_sankey.R
|
||||
########
|
||||
|
||||
#' Readying data for sankey plot
|
||||
|
@ -3900,7 +3652,7 @@ plot_sankey_single <- function(data, x, y, color.group = c("x", "y"), colors = N
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//plot_scatter.R
|
||||
#### Current file: R//plot_scatter.R
|
||||
########
|
||||
|
||||
#' Beautiful violin plot
|
||||
|
@ -3931,7 +3683,7 @@ plot_scatter <- function(data, x, y, z = NULL) {
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//plot_violin.R
|
||||
#### Current file: R//plot_violin.R
|
||||
########
|
||||
|
||||
#' Beatiful violin plot
|
||||
|
@ -3964,7 +3716,7 @@ plot_violin <- function(data, x, y, z = NULL) {
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//redcap_read_shiny_module.R
|
||||
#### Current file: R//redcap_read_shiny_module.R
|
||||
########
|
||||
|
||||
#' Shiny module to browser and export REDCap data
|
||||
|
@ -4551,14 +4303,14 @@ redcap_demo_app <- function() {
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//redcap.R
|
||||
#### Current file: R//redcap.R
|
||||
########
|
||||
|
||||
|
||||
|
||||
|
||||
########
|
||||
#### Current file: R//regression_model.R
|
||||
#### Current file: R//regression_model.R
|
||||
########
|
||||
|
||||
#' Create a regression model programatically
|
||||
|
@ -5200,7 +4952,7 @@ regression_model_uv_list <- function(data,
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//regression_plot.R
|
||||
#### Current file: R//regression_plot.R
|
||||
########
|
||||
|
||||
#' Regression coef plot from gtsummary. Slightly modified to pass on arguments
|
||||
|
@ -5220,16 +4972,15 @@ regression_model_uv_list <- function(data,
|
|||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' mod <- lm(mpg ~ ., default_parsing(mtcars))
|
||||
#' mod <- lm(mpg ~ ., mtcars)
|
||||
#' p <- mod |>
|
||||
#' gtsummary::tbl_regression() |>
|
||||
#' plot(colour = "variable")
|
||||
#' }
|
||||
#'
|
||||
plot.tbl_regression <- function(x,
|
||||
plot_ref = TRUE,
|
||||
remove_header_rows = TRUE,
|
||||
remove_reference_rows = FALSE,
|
||||
# remove_header_rows = TRUE,
|
||||
# remove_reference_rows = FALSE,
|
||||
...) {
|
||||
# check_dots_empty()
|
||||
gtsummary:::check_pkg_installed("ggstats")
|
||||
|
@ -5238,31 +4989,33 @@ 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)
|
||||
# }
|
||||
|
||||
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)
|
||||
}
|
||||
# browser()
|
||||
|
||||
# Removes redundant label
|
||||
df_coefs$label[df_coefs$row_type == "label"] <- ""
|
||||
|
||||
# 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}
|
||||
|
||||
p <- df_coefs |>
|
||||
df_coefs %>%
|
||||
ggstats::ggcoef_plot(exponentiate = x$inputs$exponentiate, ...)
|
||||
|
||||
if (x$inputs$exponentiate){
|
||||
p <- symmetrical_scale_x_log10(p)
|
||||
}
|
||||
p
|
||||
}
|
||||
|
||||
|
||||
# default_parsing(mtcars) |> lapply(class)
|
||||
#
|
||||
# purrr::imap(mtcars,\(.x,.i){
|
||||
# if (.i %in% c("vs","am","gear","carb")){
|
||||
# as.factor(.x)
|
||||
# } else .x
|
||||
# }) |> dplyr::bind_cols()
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
#' Wrapper to pivot gtsummary table data to long for plotting
|
||||
#'
|
||||
#' @param list a custom regression models list
|
||||
|
@ -5304,52 +5057,8 @@ merge_long <- function(list, model.names) {
|
|||
}
|
||||
|
||||
|
||||
#' Easily round log scale limits for nice plots
|
||||
#'
|
||||
#' @param data data
|
||||
#' @param fun rounding function (floor/ceiling)
|
||||
#' @param ... ignored
|
||||
#'
|
||||
#' @returns numeric vector
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' limit_log(-.1,floor)
|
||||
#' limit_log(.1,ceiling)
|
||||
#' limit_log(-2.1,ceiling)
|
||||
#' limit_log(2.1,ceiling)
|
||||
limit_log <- function(data,fun,...){
|
||||
fun(10^-floor(data)*10^data)/10^-floor(data)
|
||||
}
|
||||
|
||||
#' Ensure symmetrical plot around 1 on a logarithmic x scale for ratio plots
|
||||
#'
|
||||
#' @param plot ggplot2 plot
|
||||
#' @param breaks breaks used and mirrored
|
||||
#' @param ... ignored
|
||||
#'
|
||||
#' @returns ggplot2 object
|
||||
#' @export
|
||||
#'
|
||||
symmetrical_scale_x_log10 <- function(plot,breaks=c(1,2,3,5,10),...){
|
||||
rx <- ggplot2::layer_scales(plot)$x$get_limits()
|
||||
|
||||
x_min <- floor(10*rx[1])/10
|
||||
x_max <- ceiling(10*rx[2])/10
|
||||
|
||||
rx_min <- limit_log(rx[1],floor)
|
||||
rx_max <- limit_log(rx[2],ceiling)
|
||||
|
||||
max_abs_x <- max(abs(c(x_min,x_max)))
|
||||
|
||||
ticks <- log10(breaks)+(ceiling(max_abs_x)-1)
|
||||
|
||||
plot + ggplot2::scale_x_log10(limits=c(rx_min,rx_max),breaks=create_log_tics(10^ticks[ticks<=max_abs_x]))
|
||||
}
|
||||
|
||||
|
||||
########
|
||||
#### Current file: R//regression_table.R
|
||||
#### Current file: R//regression_table.R
|
||||
########
|
||||
|
||||
#' Create table of regression model
|
||||
|
@ -5435,7 +5144,7 @@ symmetrical_scale_x_log10 <- function(plot,breaks=c(1,2,3,5,10),...){
|
|||
#' #' @export
|
||||
#' regression_table.default <- function(x, ..., args.list = NULL, fun = "gtsummary::tbl_regression") {
|
||||
#' # Stripping custom class
|
||||
#' class(x) <- class(x)[class(x) != "freesearchr_model"]
|
||||
#' class(x) <- class(x)[class(x) != "freesearcher_model"]
|
||||
#'
|
||||
#' if (any(c(length(class(x)) != 1, class(x) != "lm"))) {
|
||||
#' if (!"exponentiate" %in% names(args.list)) {
|
||||
|
@ -5464,7 +5173,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) != "freesearchr_model"]
|
||||
class(x) <- class(x)[class(x) != "freesearcher_model"]
|
||||
|
||||
if (any(c(length(class(x)) != 1, class(x) != "lm"))) {
|
||||
if (!"exponentiate" %in% names(args.list)) {
|
||||
|
@ -5500,7 +5209,7 @@ tbl_merge <- function(data) {
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//report.R
|
||||
#### Current file: R//report.R
|
||||
########
|
||||
|
||||
#' Split vector by an index and embed addition
|
||||
|
@ -5588,7 +5297,50 @@ modify_qmd <- function(file, format) {
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//theme.R
|
||||
#### Current file: R//shiny_freesearcheR.R
|
||||
########
|
||||
|
||||
#' 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(...)
|
||||
}
|
||||
|
||||
|
||||
########
|
||||
#### Current file: R//theme.R
|
||||
########
|
||||
|
||||
#' Custom theme based on unity
|
||||
|
@ -5670,7 +5422,7 @@ gg_theme_export <- function(){
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//update-factor-ext.R
|
||||
#### Current file: R//update-factor-ext.R
|
||||
########
|
||||
|
||||
|
||||
|
@ -5940,7 +5692,7 @@ modal_update_factor <- function(id,
|
|||
#'
|
||||
#' @importFrom shinyWidgets WinBox wbOptions wbControls
|
||||
#' @importFrom htmltools tagList
|
||||
#' @rdname update-factor
|
||||
#' @rdname create-column
|
||||
winbox_update_factor <- function(id,
|
||||
title = i18n("Update levels of a factor"),
|
||||
options = shinyWidgets::wbOptions(),
|
||||
|
@ -5967,7 +5719,7 @@ winbox_update_factor <- function(id,
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//update-variables-ext.R
|
||||
#### Current file: R//update-variables-ext.R
|
||||
########
|
||||
|
||||
library(data.table)
|
||||
|
@ -6749,7 +6501,7 @@ clean_date <- function(data){
|
|||
|
||||
|
||||
########
|
||||
#### Current file: R//wide2long.R
|
||||
#### Current file: R//wide2long.R
|
||||
########
|
||||
|
||||
#' Alternative pivoting method for easily pivoting based on name pattern
|
||||
|
@ -6908,7 +6660,7 @@ grepl_fix <- function(data, pattern, type = c("prefix", "infix", "suffix")) {
|
|||
|
||||
|
||||
########
|
||||
#### Current file: /Users/au301842/FreesearchR/inst/apps/FreesearchR/ui.R
|
||||
#### Current file: /Users/au301842/freesearcheR/inst/apps/freesearcheR/ui.R
|
||||
########
|
||||
|
||||
# ns <- NS(id)
|
||||
|
@ -6920,7 +6672,7 @@ ui_elements <- list(
|
|||
#########
|
||||
##############################################################################
|
||||
"home" = bslib::nav_panel(
|
||||
title = "FreesearchR",
|
||||
title = "freesearcheR",
|
||||
shiny::fluidRow(
|
||||
shiny::column(width = 2),
|
||||
shiny::column(
|
||||
|
@ -7462,8 +7214,7 @@ ui_elements <- list(
|
|||
),
|
||||
shiny::br(),
|
||||
shiny::br(),
|
||||
shiny::h4("Code snippets"),
|
||||
shiny::tags$p("Below are the code used to create the final data set. This can be saved for reproducibility. The code may not be 100 % correct, but kan be used for learning and example code to get started on coding yourself."),
|
||||
shiny::tags$b("Code snippets:"),
|
||||
shiny::verbatimTextOutput(outputId = "code_import"),
|
||||
shiny::verbatimTextOutput(outputId = "code_data"),
|
||||
shiny::verbatimTextOutput(outputId = "code_filter"),
|
||||
|
@ -7511,10 +7262,10 @@ ui <- bslib::page_fixed(
|
|||
# add the name of the tab you want to use as title in data-value
|
||||
shiny::HTML(
|
||||
".container-fluid > .nav > li >
|
||||
a[data-value='FreesearchR'] {font-size: 28px}"
|
||||
a[data-value='freesearcheR'] {font-size: 28px}"
|
||||
)
|
||||
),
|
||||
title = "FreesearchR",
|
||||
title = "freesearcheR",
|
||||
theme = light,
|
||||
shiny::useBusyIndicators(),
|
||||
bslib::page_navbar(
|
||||
|
@ -7537,7 +7288,7 @@ ui <- bslib::page_fixed(
|
|||
),
|
||||
shiny::p(
|
||||
style = "margin: 1; color: #888;",
|
||||
"AG Damsbo | v", app_version(), " | ",shiny::tags$a("AGPLv3 license", href = "https://github.com/agdamsbo/FreesearchR/blob/main/LICENSE.md", target = "_blank", rel = "noopener noreferrer")," | ", shiny::tags$a("Source on Github", href = "https://github.com/agdamsbo/FreesearchR/", target = "_blank", rel = "noopener noreferrer")
|
||||
"AG Damsbo | v", app_version(), " | AGPLv3 license | ", shiny::tags$a("Source on Github", href = "https://github.com/agdamsbo/FreesearchR/", target = "_blank", rel = "noopener noreferrer")
|
||||
),
|
||||
)
|
||||
)
|
||||
|
@ -7545,7 +7296,7 @@ ui <- bslib::page_fixed(
|
|||
|
||||
|
||||
########
|
||||
#### Current file: /Users/au301842/FreesearchR/inst/apps/FreesearchR/server.R
|
||||
#### Current file: /Users/au301842/freesearcheR/inst/apps/freesearcheR/server.R
|
||||
########
|
||||
|
||||
library(readr)
|
||||
|
@ -7576,7 +7327,7 @@ library(IDEAFilter)
|
|||
library(shinyWidgets)
|
||||
library(DT)
|
||||
library(gtsummary)
|
||||
# library(FreesearchR)
|
||||
# library(freesearcheR)
|
||||
|
||||
# source("functions.R")
|
||||
|
||||
|
@ -7724,7 +7475,7 @@ server <- function(input, output, session) {
|
|||
paste(collapse = "") |>
|
||||
paste("|>
|
||||
dplyr::select(", paste(input$import_var, collapse = ","), ") |>
|
||||
FreesearchR::default_parsing()") |>
|
||||
freesearcheR::default_parsing()") |>
|
||||
(\(.x){
|
||||
paste0("data <- ", .x)
|
||||
})()
|
||||
|
@ -7784,6 +7535,11 @@ server <- function(input, output, session) {
|
|||
)
|
||||
})
|
||||
|
||||
# shiny::observeEvent(input$reset_confirm, {
|
||||
# rv$data <- rv$data_original |> default_parsing()
|
||||
# })
|
||||
|
||||
|
||||
|
||||
#########
|
||||
######### Modifications
|
||||
|
@ -7856,6 +7612,7 @@ server <- function(input, output, session) {
|
|||
}
|
||||
)
|
||||
|
||||
|
||||
######### Subset, rename, reclass
|
||||
|
||||
updated_data <- update_variables_server(
|
||||
|
@ -7869,6 +7626,8 @@ server <- function(input, output, session) {
|
|||
rv$code$modify[[length(rv$code$modify) + 1]] <- attr(rv$data, "code")
|
||||
})
|
||||
|
||||
|
||||
|
||||
######### Data filter
|
||||
# IDEAFilter has the least cluttered UI, but might have a License issue
|
||||
data_filter <- IDEAFilter::IDEAFilter("data_filter",
|
||||
|
@ -8006,6 +7765,7 @@ server <- function(input, output, session) {
|
|||
})
|
||||
|
||||
output$code_filter <- shiny::renderPrint({
|
||||
shiny::req(rv$code$filter)
|
||||
cat(rv$code$filter)
|
||||
})
|
||||
|
||||
|
@ -8527,7 +8287,7 @@ server <- function(input, output, session) {
|
|||
|
||||
|
||||
########
|
||||
#### Current file: /Users/au301842/FreesearchR/inst/apps/FreesearchR/launch.R
|
||||
#### Current file: /Users/au301842/freesearcheR/inst/apps/freesearcheR/launch.R
|
||||
########
|
||||
|
||||
shinyApp(ui, server)
|
|
@ -5,6 +5,6 @@ account: agdamsbo
|
|||
server: shinyapps.io
|
||||
hostUrl: https://api.shinyapps.io/v1
|
||||
appId: 13611288
|
||||
bundleId: 9969300
|
||||
bundleId: 9958862
|
||||
url: https://agdamsbo.shinyapps.io/freesearcheR/
|
||||
version: 1
|
|
@ -26,7 +26,7 @@ library(IDEAFilter)
|
|||
library(shinyWidgets)
|
||||
library(DT)
|
||||
library(gtsummary)
|
||||
# library(FreesearchR)
|
||||
# library(freesearcheR)
|
||||
|
||||
# source("functions.R")
|
||||
|
||||
|
@ -174,7 +174,7 @@ server <- function(input, output, session) {
|
|||
paste(collapse = "") |>
|
||||
paste("|>
|
||||
dplyr::select(", paste(input$import_var, collapse = ","), ") |>
|
||||
FreesearchR::default_parsing()") |>
|
||||
freesearcheR::default_parsing()") |>
|
||||
(\(.x){
|
||||
paste0("data <- ", .x)
|
||||
})()
|
|
@ -7,7 +7,7 @@ ui_elements <- list(
|
|||
#########
|
||||
##############################################################################
|
||||
"home" = bslib::nav_panel(
|
||||
title = "FreesearchR",
|
||||
title = "freesearcheR",
|
||||
shiny::fluidRow(
|
||||
shiny::column(width = 2),
|
||||
shiny::column(
|
||||
|
@ -598,10 +598,10 @@ ui <- bslib::page_fixed(
|
|||
# add the name of the tab you want to use as title in data-value
|
||||
shiny::HTML(
|
||||
".container-fluid > .nav > li >
|
||||
a[data-value='FreesearchR'] {font-size: 28px}"
|
||||
a[data-value='freesearcheR'] {font-size: 28px}"
|
||||
)
|
||||
),
|
||||
title = "FreesearchR",
|
||||
title = "freesearcheR",
|
||||
theme = light,
|
||||
shiny::useBusyIndicators(),
|
||||
bslib::page_navbar(
|
||||
|
@ -624,7 +624,7 @@ ui <- bslib::page_fixed(
|
|||
),
|
||||
shiny::p(
|
||||
style = "margin: 1; color: #888;",
|
||||
"AG Damsbo | v", app_version(), " | ",shiny::tags$a("AGPLv3 license", href = "https://github.com/agdamsbo/FreesearchR/blob/main/LICENSE.md", target = "_blank", rel = "noopener noreferrer")," | ", shiny::tags$a("Source on Github", href = "https://github.com/agdamsbo/FreesearchR/", target = "_blank", rel = "noopener noreferrer")
|
||||
"AG Damsbo | v", app_version(), " | AGPLv3 license | ", shiny::tags$a("Source on Github", href = "https://github.com/agdamsbo/FreesearchR/", target = "_blank", rel = "noopener noreferrer")
|
||||
),
|
||||
)
|
||||
)
|
|
@ -1,6 +1,6 @@
|
|||
# Welcome
|
||||
|
||||
This is the ***FreesearchR*** data analysis tool. We intend the ***FreesearchR*** to be a powerful and free tool for easy data evaluation and analysis at the hands of the clinician. If you need more advanced tools for regression models or plotting, you'll probably be better off using *R* or similar directly on your own machine.
|
||||
This is the ***freesearcheR*** data analysis tool. We intend the ***freesearcheR*** to be a powerful and free tool for easy data evaluation and analysis at the hands of the clinician. If you need more advanced tools for regression models or plotting, you'll probably be better off using *R* or similar directly on your own machine.
|
||||
|
||||
By intention, this tool has been designed to be simple to use with a minimum of mandatory options to keep the workflow streamlined, while also including a few options to go even further.
|
||||
|
||||
|
@ -24,6 +24,6 @@ There are some simple steps to go through (see corresponding tabs in the top):
|
|||
|
||||
1. Export the the analyses results for MS Word or [LibreOffice](https://www.libreoffice.org/) as well as the data with preserved metadata.
|
||||
|
||||
The full [project documentation is here](https://agdamsbo.github.io/FreesearchR/) for documenting the project, functions, road map and more. If you're interested in the source code, then [everything is open and you are free to read, copy, modify and improve](https://github.com/agdamsbo/FreesearchR), and please let us know if you want to contribute!
|
||||
Have a look at the [documentations page](https://agdamsbo.github.io/freesearcheR/) for further project description. If you're interested in the source code, then go on, [have a look](https://github.com/agdamsbo/freesearcheR)!
|
||||
|
||||
Contributions can be reporting issues, suggesting new functionality, improving code or any other feedback. [It all goes here](https://github.com/agdamsbo/FreesearchR/issues).
|
||||
If you encounter anything strange or the app doesn't act as expected. Please [report on Github](https://github.com/agdamsbo/freesearcheR/issues).
|
11
inst/apps/freesearcheR/www/notes_visuals.md
Normal file
11
inst/apps/freesearcheR/www/notes_visuals.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Basic visualisations
|
||||
|
||||
This section on plotting data is kept very minimal, and includes only the most common plot types for clinical projects.
|
||||
|
||||
If you want to go further, have a look at these sites with suggestions and sample code for data plotting:
|
||||
|
||||
- [*R* Charts](https://r-charts.com/): Extensive gallery with great plots
|
||||
|
||||
- [*R* Graph gallery](https://r-graph-gallery.com/): Another gallery with great graphs
|
||||
|
||||
- [grphics principles](https://graphicsprinciples.github.io/): Easy to follow recommendations for clear visuals.
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
title: "FreesearchR data report"
|
||||
title: "freesearcheR data report"
|
||||
date: "Report generated `r gsub('(\\D)0', '\\1', format(Sys.time(), '%A, %d.%m.%Y'))`"
|
||||
format: docx
|
||||
author: FreesearchR data analysis tool
|
||||
author: freesearcheR data analysis tool
|
||||
toc: false
|
||||
params:
|
||||
data.file: NA
|
||||
|
@ -13,6 +13,7 @@ knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
|
|||
# glue::glue("{format(lubridate::today(),'%A')}, {lubridate::day(lubridate::today())}.{lubridate::month(lubridate::today())}.{lubridate::year(lubridate::today())}")
|
||||
```
|
||||
|
||||
|
||||
```{r}
|
||||
web_data <- readr::read_rds(file = params$data.file)
|
||||
library(gtsummary)
|
||||
|
@ -41,11 +42,11 @@ vec2sentence <- function(data, sep.word = "and") {
|
|||
|
||||
## Introduction
|
||||
|
||||
Research should be free and open with easy access for all. The FreesearchR tool attempts to help lower the bar to participate in contributing to science by making guided data analysis easily accessible in the web-browser.
|
||||
Research should be free and open with easy access for all. The freesearcheR tool attempts to help lower the bar to participate in contributing to science by making guided data analysis easily accessible in the web-browser.
|
||||
|
||||
## Methods
|
||||
|
||||
Analyses were conducted in the *FreesearchR* data analysis web-tool based on R version 4.4.1.
|
||||
Analyses were conducted in the *freesearcheR* data analysis web-tool based on R version 4.4.1.
|
||||
|
||||
## Results
|
||||
|
||||
|
@ -69,4 +70,3 @@ knitr::knit_print(tbl_merge(reg_tbl))
|
|||
## Discussion
|
||||
|
||||
Good luck on your further work!
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/data_plots.R
|
||||
\name{allign_axes}
|
||||
\alias{allign_axes}
|
||||
\title{Alligns axes between plots}
|
||||
\usage{
|
||||
allign_axes(...)
|
||||
}
|
||||
\arguments{
|
||||
\item{...}{ggplot2 objects or list of ggplot2 objects}
|
||||
}
|
||||
\value{
|
||||
list of ggplot2 objects
|
||||
}
|
||||
\description{
|
||||
Alligns axes between plots
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/launch_FreesearchR.R
|
||||
\name{launch_FreesearchR}
|
||||
\alias{launch_FreesearchR}
|
||||
\title{Easily launch the FreesearchR app}
|
||||
\usage{
|
||||
launch_FreesearchR(...)
|
||||
}
|
||||
\arguments{
|
||||
\item{...}{passed on to \code{shiny::runApp()}}
|
||||
}
|
||||
\value{
|
||||
shiny app
|
||||
}
|
||||
\description{
|
||||
All data.frames in the global environment will be accessible through the app.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(mtcars)
|
||||
shiny_FreesearchR(launch.browser = TRUE)
|
||||
}
|
||||
}
|
17
man/launch_freesearcheR.Rd
Normal file
17
man/launch_freesearcheR.Rd
Normal file
|
@ -0,0 +1,17 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/shiny_freesearcheR.R
|
||||
\name{launch_freesearcheR}
|
||||
\alias{launch_freesearcheR}
|
||||
\title{Easily launch the freesearcheR app}
|
||||
\usage{
|
||||
launch_freesearcheR(...)
|
||||
}
|
||||
\arguments{
|
||||
\item{...}{passed on to \code{shiny::runApp()}}
|
||||
}
|
||||
\value{
|
||||
shiny app
|
||||
}
|
||||
\description{
|
||||
Easily launch the freesearcheR app
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/regression_plot.R
|
||||
\name{limit_log}
|
||||
\alias{limit_log}
|
||||
\title{Easily round log scale limits for nice plots}
|
||||
\usage{
|
||||
limit_log(data, fun, ...)
|
||||
}
|
||||
\arguments{
|
||||
\item{data}{data}
|
||||
|
||||
\item{fun}{rounding function (floor/ceiling)}
|
||||
|
||||
\item{...}{ignored}
|
||||
}
|
||||
\value{
|
||||
numeric vector
|
||||
}
|
||||
\description{
|
||||
Easily round log scale limits for nice plots
|
||||
}
|
||||
\examples{
|
||||
limit_log(-.1,floor)
|
||||
limit_log(.1,ceiling)
|
||||
limit_log(-2.1,ceiling)
|
||||
limit_log(2.1,ceiling)
|
||||
}
|
|
@ -4,13 +4,7 @@
|
|||
\alias{plot.tbl_regression}
|
||||
\title{Regression coef plot from gtsummary. Slightly modified to pass on arguments}
|
||||
\usage{
|
||||
\method{plot}{tbl_regression}(
|
||||
x,
|
||||
plot_ref = TRUE,
|
||||
remove_header_rows = TRUE,
|
||||
remove_reference_rows = FALSE,
|
||||
...
|
||||
)
|
||||
\method{plot}{tbl_regression}(x, ...)
|
||||
}
|
||||
\arguments{
|
||||
\item{x}{(\code{tbl_regression}, \code{tbl_uvregression})\cr
|
||||
|
@ -26,7 +20,7 @@ Regression coef plot from gtsummary. Slightly modified to pass on arguments
|
|||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
mod <- lm(mpg ~ ., default_parsing(mtcars))
|
||||
mod <- lm(mpg ~ ., mtcars)
|
||||
p <- mod |>
|
||||
gtsummary::tbl_regression() |>
|
||||
plot(colour = "variable")
|
||||
|
|
|
@ -93,7 +93,7 @@ regression_table.list <- function(x, ...) {
|
|||
#' @export
|
||||
regression_table.default <- function(x, ..., args.list = NULL, fun = "gtsummary::tbl_regression") {
|
||||
# Stripping custom class
|
||||
class(x) <- class(x)[class(x) != "freesearchr_model"]
|
||||
class(x) <- class(x)[class(x) != "freesearcher_model"]
|
||||
|
||||
if (any(c(length(class(x)) != 1, class(x) != "lm"))) {
|
||||
if (!"exponentiate" \%in\% names(args.list)) {
|
||||
|
|
23
man/shiny_freesearcheR.Rd
Normal file
23
man/shiny_freesearcheR.Rd
Normal file
|
@ -0,0 +1,23 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/shiny_freesearcheR.R
|
||||
\name{shiny_freesearcheR}
|
||||
\alias{shiny_freesearcheR}
|
||||
\title{Launch the freesearcheR tool locally}
|
||||
\usage{
|
||||
shiny_freesearcheR(...)
|
||||
}
|
||||
\arguments{
|
||||
\item{...}{arguments passed on to \code{shiny::runApp()}}
|
||||
}
|
||||
\value{
|
||||
shiny app
|
||||
}
|
||||
\description{
|
||||
All data.frames in the global environment will be accessible through the app.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
data(mtcars)
|
||||
shiny_freesearcheR(launch.browser = TRUE)
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/regression_plot.R
|
||||
\name{symmetrical_scale_x_log10}
|
||||
\alias{symmetrical_scale_x_log10}
|
||||
\title{Ensure symmetrical plot around 1 on a logarithmic x scale for ratio plots}
|
||||
\usage{
|
||||
symmetrical_scale_x_log10(plot, breaks = c(1, 2, 3, 5, 10), ...)
|
||||
}
|
||||
\arguments{
|
||||
\item{plot}{ggplot2 plot}
|
||||
|
||||
\item{breaks}{breaks used and mirrored}
|
||||
|
||||
\item{...}{ignored}
|
||||
}
|
||||
\value{
|
||||
ggplot2 object
|
||||
}
|
||||
\description{
|
||||
Ensure symmetrical plot around 1 on a logarithmic x scale for ratio plots
|
||||
}
|
|
@ -5,7 +5,6 @@
|
|||
\alias{update_factor_ui}
|
||||
\alias{update_factor_server}
|
||||
\alias{modal_update_factor}
|
||||
\alias{winbox_update_factor}
|
||||
\title{Module to Reorder the Levels of a Factor Variable}
|
||||
\usage{
|
||||
update_factor_ui(id)
|
||||
|
@ -19,13 +18,6 @@ modal_update_factor(
|
|||
size = "l",
|
||||
footer = NULL
|
||||
)
|
||||
|
||||
winbox_update_factor(
|
||||
id,
|
||||
title = i18n("Update levels of a factor"),
|
||||
options = shinyWidgets::wbOptions(),
|
||||
controls = shinyWidgets::wbControls()
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{id}{Module ID.}
|
||||
|
@ -47,10 +39,6 @@ pass \code{\link[bslib:bs_theme]{bslib::bs_theme()}} to the \code{theme} argumen
|
|||
like \code{\link[shiny:fluidPage]{fluidPage()}}).}
|
||||
|
||||
\item{footer}{UI for footer. Use \code{NULL} for no footer.}
|
||||
|
||||
\item{options}{List of options, see \code{\link[shinyWidgets:wbOptions]{wbOptions()}}.}
|
||||
|
||||
\item{controls}{List of controls, see \code{\link[shinyWidgets:wbControls]{wbControls()}}.}
|
||||
}
|
||||
\value{
|
||||
A \code{\link[shiny:reactive]{shiny::reactive()}} function returning the data.
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/data_plots.R
|
||||
\name{wrap_plot_list}
|
||||
\alias{wrap_plot_list}
|
||||
\title{Wrapping}
|
||||
\usage{
|
||||
wrap_plot_list(data, tag_levels = NULL)
|
||||
}
|
||||
\arguments{
|
||||
\item{data}{list of ggplot2 objects}
|
||||
|
||||
\item{tag_levels}{passed to patchwork::plot_annotation if given. Default is NULL}
|
||||
}
|
||||
\value{
|
||||
list of ggplot2 objects
|
||||
}
|
||||
\description{
|
||||
Wrapping
|
||||
}
|
89
renv.lock
89
renv.lock
File diff suppressed because one or more lines are too long
|
@ -2,7 +2,7 @@
|
|||
local({
|
||||
|
||||
# the requested version of renv
|
||||
version <- "1.1.3"
|
||||
version <- "1.1.2"
|
||||
attr(version, "sha") <- NULL
|
||||
|
||||
# the project directory
|
||||
|
@ -695,19 +695,11 @@ local({
|
|||
|
||||
}
|
||||
|
||||
renv_bootstrap_platform_prefix_default <- function() {
|
||||
renv_bootstrap_platform_prefix <- function() {
|
||||
|
||||
# read version component
|
||||
version <- Sys.getenv("RENV_PATHS_VERSION", unset = "R-%v")
|
||||
|
||||
# expand placeholders
|
||||
placeholders <- list(
|
||||
list("%v", format(getRversion()[1, 1:2])),
|
||||
list("%V", format(getRversion()[1, 1:3]))
|
||||
)
|
||||
|
||||
for (placeholder in placeholders)
|
||||
version <- gsub(placeholder[[1L]], placeholder[[2L]], version, fixed = TRUE)
|
||||
# construct version prefix
|
||||
version <- paste(R.version$major, R.version$minor, sep = ".")
|
||||
prefix <- paste("R", numeric_version(version)[1, 1:2], sep = "-")
|
||||
|
||||
# include SVN revision for development versions of R
|
||||
# (to avoid sharing platform-specific artefacts with released versions of R)
|
||||
|
@ -716,19 +708,10 @@ local({
|
|||
identical(R.version[["nickname"]], "Unsuffered Consequences")
|
||||
|
||||
if (devel)
|
||||
version <- paste(version, R.version[["svn rev"]], sep = "-r")
|
||||
|
||||
version
|
||||
|
||||
}
|
||||
|
||||
renv_bootstrap_platform_prefix <- function() {
|
||||
|
||||
# construct version prefix
|
||||
version <- renv_bootstrap_platform_prefix_default()
|
||||
prefix <- paste(prefix, R.version[["svn rev"]], sep = "-r")
|
||||
|
||||
# build list of path components
|
||||
components <- c(version, R.version$platform)
|
||||
components <- c(prefix, R.version$platform)
|
||||
|
||||
# include prefix if provided by user
|
||||
prefix <- renv_bootstrap_platform_prefix_impl()
|
||||
|
@ -967,14 +950,14 @@ local({
|
|||
}
|
||||
|
||||
renv_bootstrap_validate_version_dev <- function(version, description) {
|
||||
|
||||
|
||||
expected <- description[["RemoteSha"]]
|
||||
if (!is.character(expected))
|
||||
return(FALSE)
|
||||
|
||||
|
||||
pattern <- sprintf("^\\Q%s\\E", version)
|
||||
grepl(pattern, expected, perl = TRUE)
|
||||
|
||||
|
||||
}
|
||||
|
||||
renv_bootstrap_validate_version_release <- function(version, description) {
|
||||
|
@ -1215,89 +1198,86 @@ local({
|
|||
}
|
||||
|
||||
renv_json_read_patterns <- function() {
|
||||
|
||||
|
||||
list(
|
||||
|
||||
|
||||
# objects
|
||||
list("{", "\t\n\tobject(\t\n\t", TRUE),
|
||||
list("}", "\t\n\t)\t\n\t", TRUE),
|
||||
|
||||
list("{", "\t\n\tobject(\t\n\t"),
|
||||
list("}", "\t\n\t)\t\n\t"),
|
||||
|
||||
# arrays
|
||||
list("[", "\t\n\tarray(\t\n\t", TRUE),
|
||||
list("]", "\n\t\n)\n\t\n", TRUE),
|
||||
|
||||
list("[", "\t\n\tarray(\t\n\t"),
|
||||
list("]", "\n\t\n)\n\t\n"),
|
||||
|
||||
# maps
|
||||
list(":", "\t\n\t=\t\n\t", TRUE),
|
||||
|
||||
# newlines
|
||||
list("\\u000a", "\n", FALSE)
|
||||
|
||||
list(":", "\t\n\t=\t\n\t")
|
||||
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
|
||||
renv_json_read_envir <- function() {
|
||||
|
||||
envir <- new.env(parent = emptyenv())
|
||||
|
||||
|
||||
envir[["+"]] <- `+`
|
||||
envir[["-"]] <- `-`
|
||||
|
||||
|
||||
envir[["object"]] <- function(...) {
|
||||
result <- list(...)
|
||||
names(result) <- as.character(names(result))
|
||||
result
|
||||
}
|
||||
|
||||
|
||||
envir[["array"]] <- list
|
||||
|
||||
|
||||
envir[["true"]] <- TRUE
|
||||
envir[["false"]] <- FALSE
|
||||
envir[["null"]] <- NULL
|
||||
|
||||
|
||||
envir
|
||||
|
||||
|
||||
}
|
||||
|
||||
renv_json_read_remap <- function(object, patterns) {
|
||||
|
||||
|
||||
# repair names if necessary
|
||||
if (!is.null(names(object))) {
|
||||
|
||||
|
||||
nms <- names(object)
|
||||
for (pattern in patterns)
|
||||
nms <- gsub(pattern[[2L]], pattern[[1L]], nms, fixed = TRUE)
|
||||
names(object) <- nms
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
# repair strings if necessary
|
||||
if (is.character(object)) {
|
||||
for (pattern in patterns)
|
||||
object <- gsub(pattern[[2L]], pattern[[1L]], object, fixed = TRUE)
|
||||
}
|
||||
|
||||
|
||||
# recurse for other objects
|
||||
if (is.recursive(object))
|
||||
for (i in seq_along(object))
|
||||
object[i] <- list(renv_json_read_remap(object[[i]], patterns))
|
||||
|
||||
|
||||
# return remapped object
|
||||
object
|
||||
|
||||
|
||||
}
|
||||
|
||||
renv_json_read_default <- function(file = NULL, text = NULL) {
|
||||
|
||||
# read json text
|
||||
text <- paste(text %||% readLines(file, warn = FALSE), collapse = "\n")
|
||||
|
||||
|
||||
# convert into something the R parser will understand
|
||||
patterns <- renv_json_read_patterns()
|
||||
transformed <- text
|
||||
for (pattern in patterns)
|
||||
transformed <- gsub(pattern[[1L]], pattern[[2L]], transformed, fixed = TRUE)
|
||||
|
||||
|
||||
# parse it
|
||||
rfile <- tempfile("renv-json-", fileext = ".R")
|
||||
on.exit(unlink(rfile), add = TRUE)
|
||||
|
@ -1307,10 +1287,9 @@ local({
|
|||
# evaluate in safe environment
|
||||
result <- eval(json, envir = renv_json_read_envir())
|
||||
|
||||
# fix up strings if necessary -- do so only with reversible patterns
|
||||
patterns <- Filter(function(pattern) pattern[[3L]], patterns)
|
||||
# fix up strings if necessary
|
||||
renv_json_read_remap(result, patterns)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
title: "FreesearchR"
|
||||
title: "freesearcheR"
|
||||
output: rmarkdown::html_vignette
|
||||
vignette: >
|
||||
%\VignetteIndexEntry{FreesearchR}
|
||||
%\VignetteIndexEntry{freesearcheR}
|
||||
%\VignetteEngine{knitr::rmarkdown}
|
||||
%\VignetteEncoding{UTF-8}
|
||||
---
|
||||
|
@ -11,9 +11,9 @@ vignette: >
|
|||
knitr::opts_chunk$set(echo = TRUE,eval = FALSE)
|
||||
```
|
||||
|
||||
# Getting started with ***FreesearchR***
|
||||
# Getting started with ***freesearcheR***
|
||||
|
||||
Below is a simple walk-trough and basic instructions for the functions on the FreesearchR app.
|
||||
Below is a simple walk-trough and basic instructions for the functions on the freesearcheR app.
|
||||
|
||||
## Launching
|
||||
|
||||
|
@ -21,13 +21,13 @@ The easiest way to get started is to launch [the hosted version of the app on sh
|
|||
|
||||
Additionally you have the option to run the app locally with access to any data in your current working environment.
|
||||
|
||||
To do this, open *R* (or RStudio or similar), and run the following code to install the latest version of ***FreesearchR*** and launch the app:
|
||||
To do this, open *R* (or RStudio or similar), and run the following code to install the latest version of ***freesearcheR*** and launch the app:
|
||||
|
||||
```{r}
|
||||
``` {r}
|
||||
require("pak")
|
||||
pak::pak("agdamsbo/FreesearchR")
|
||||
library(FreesearchR)
|
||||
FreesearchR::launch_FreesearchR()
|
||||
pak::pak("agdamsbo/freesearcheR")
|
||||
library(freesearcheR)
|
||||
freesearcheR::launch_freesearcheR()
|
||||
```
|
||||
|
||||
As a small note, a standalone Windows app version is on the drawing board as well, but no time frame is available.
|
Loading…
Add table
Reference in a new issue