limiting dependencies

This commit is contained in:
Andreas Gammelgaard Damsbo 2025-04-23 14:24:07 +02:00
parent 512fe1ced5
commit 2d35001c33
No known key found for this signature in database
4 changed files with 46 additions and 41 deletions

View file

@ -15,9 +15,9 @@ Imports:
dplyr, dplyr,
glue, glue,
gtsummary, gtsummary,
haven,
here, here,
quarto, quarto,
haven,
readODS, readODS,
readr, readr,
shiny, shiny,
@ -29,17 +29,14 @@ Imports:
parameters, parameters,
DT, DT,
performance, performance,
ggiraph,
qqplotr, qqplotr,
see, see,
patchwork, patchwork,
easystats, easystats,
DHARMa, DHARMa,
IDEAFilter, IDEAFilter,
sparkline,
datamods, datamods,
toastui, toastui,
webshot,
lubridate, lubridate,
bsicons, bsicons,
thematic, thematic,
@ -48,18 +45,11 @@ Imports:
classInt, classInt,
htmltools, htmltools,
rlang, rlang,
data.table,
apexcharter, apexcharter,
esquisse, esquisse,
janitor,
flextable, flextable,
gt, gt,
kableExtra,
rankinPlot, rankinPlot,
sjPlot,
gvlma,
psych,
jtools,
Hmisc, Hmisc,
ggstats, ggstats,
rempsyc, rempsyc,
@ -74,6 +64,7 @@ Suggests:
styler, styler,
devtools, devtools,
rhub, rhub,
webshot,
usethis, usethis,
roxygen2, roxygen2,
pak, pak,
@ -87,3 +78,6 @@ URL: https://github.com/agdamsbo/FreesearchR, https://agdamsbo.github.io/Freesea
BugReports: https://github.com/agdamsbo/FreesearchR/issues BugReports: https://github.com/agdamsbo/FreesearchR/issues
VignetteBuilder: knitr VignetteBuilder: knitr
Config/testthat/edition: 3 Config/testthat/edition: 3
Depends:
R (>= 3.5)
LazyData: true

View file

@ -695,7 +695,7 @@ line_break <- function(data, lineLength = 20, force = FALSE) {
#' @export #' @export
#' #'
wrap_plot_list <- function(data, tag_levels = NULL) { wrap_plot_list <- function(data, tag_levels = NULL) {
if (ggplot2::is.ggplot(data[[1]])) { if (ggplot2::is_ggplot(data[[1]])) {
if (length(data) > 1) { if (length(data) > 1) {
out <- data |> out <- data |>
(\(.x){ (\(.x){
@ -732,7 +732,7 @@ wrap_plot_list <- function(data, tag_levels = NULL) {
align_axes <- function(...) { align_axes <- function(...) {
# https://stackoverflow.com/questions/62818776/get-axis-limits-from-ggplot-object # https://stackoverflow.com/questions/62818776/get-axis-limits-from-ggplot-object
# https://github.com/thomasp85/patchwork/blob/main/R/plot_multipage.R#L150 # https://github.com/thomasp85/patchwork/blob/main/R/plot_multipage.R#L150
if (ggplot2::is.ggplot(..1)) { if (ggplot2::is_ggplot(..1)) {
## Assumes list of ggplots ## Assumes list of ggplots
p <- list(...) p <- list(...)
} else if (is.list(..1)) { } else if (is.list(..1)) {

View file

@ -87,7 +87,7 @@ read_input <- function(file, consider.na = c("NA", '""', "")) {
if (ext == "csv") { if (ext == "csv") {
df <- readr::read_csv(file = file, na = consider.na) df <- readr::read_csv(file = file, na = consider.na)
} else if (ext %in% c("xls", "xlsx")) { } else if (ext %in% c("xls", "xlsx")) {
df <- openxlsx2::read_xlsx(file = file, na.strings = consider.na) df <- readxl::read_excel(file = file, na.strings = consider.na)
} else if (ext == "dta") { } else if (ext == "dta") {
df <- haven::read_dta(file = file) df <- haven::read_dta(file = file)
} else if (ext == "ods") { } else if (ext == "ods") {
@ -428,7 +428,7 @@ sort_by <- function(x, y, na.rm = FALSE, ...) {
get_ggplot_label <- function(data, label) { get_ggplot_label <- function(data, label) {
assertthat::assert_that(ggplot2::is.ggplot(data)) assertthat::assert_that(ggplot2::is_ggplot(data))
data$labels[[label]] data$labels[[label]]
} }

View file

@ -242,7 +242,7 @@ import_file_server <- function(id,
req(input$file) req(input$file)
if (!all(input$sheet %in% temporary_rv$sheets)) { if (!all(input$sheet %in% temporary_rv$sheets)) {
sheets <- 1 sheets <- 1
} else { } else {
sheets <- input$sheet sheets <- input$sheet
} }
@ -298,31 +298,33 @@ import_file_server <- function(id,
) )
observeEvent(input$see_data, { observeEvent(input$see_data, {
tryCatch({ tryCatch(
datamods:::show_data(default_parsing(temporary_rv$data), title = datamods:::i18n("Imported data"), type = show_data_in) {
}, datamods:::show_data(default_parsing(temporary_rv$data), title = datamods:::i18n("Imported data"), type = show_data_in)
# warning = function(warn) { },
# showNotification(warn, type = "warning") # warning = function(warn) {
# }, # showNotification(warn, type = "warning")
error = function(err) { # },
showNotification(err, type = "err") error = function(err) {
} showNotification(err, type = "err")
}
) )
}) })
output$table <- toastui::renderDatagrid2({ output$table <- toastui::renderDatagrid2({
req(temporary_rv$data) req(temporary_rv$data)
tryCatch({ tryCatch(
toastui::datagrid( {
data = setNames(head(temporary_rv$data, 5),make.names(names(temporary_rv$data),unique = TRUE)), toastui::datagrid(
theme = "striped", data = setNames(head(temporary_rv$data, 5), make.names(names(temporary_rv$data), unique = TRUE)),
colwidths = "guess", theme = "striped",
minBodyHeight = 250 colwidths = "guess",
) minBodyHeight = 250
}, )
error = function(err) { },
showNotification(err, type = "err") error = function(err) {
} showNotification(err, type = "err")
}
) )
}) })
@ -418,13 +420,22 @@ import_xls <- function(file, sheet, skip, na.strings) {
sheet |> sheet |>
purrr::map(\(.x){ purrr::map(\(.x){
openxlsx2::read_xlsx( readxl::read_excel(
file = file, path = file,
sheet = .x, sheet = .x,
skip_empty_rows = TRUE, na = na.strings,
start_row = skip - 1, skip = skip,
na.strings = na.strings .name_repair = "unique_quiet",
trim_ws = TRUE
) )
# openxlsx2::read_xlsx(
# file = file,
# sheet = .x,
# skip_empty_rows = TRUE,
# start_row = skip - 1,
# na.strings = na.strings
# )
}) |> }) |>
purrr::reduce(dplyr::full_join) purrr::reduce(dplyr::full_join)
}, },