organising plotting functions - nicer plot wrapping - merge mulitple workbook sheets

This commit is contained in:
Andreas Gammelgaard Damsbo 2025-03-13 12:41:50 +01:00
commit 49016a4aa8
No known key found for this signature in database
20 changed files with 1615 additions and 910 deletions

27
R/plot_violin.R Normal file
View file

@ -0,0 +1,27 @@
#' Beatiful violin plot
#'
#' @returns ggplot2 object
#' @export
#'
#' @name data-plots
#'
#' @examples
#' mtcars |> plot_violin(x = "mpg", y = "cyl", z = "gear")
plot_violin <- function(data, x, y, z = NULL) {
if (!is.null(z)) {
ds <- split(data, data[z])
} else {
ds <- list(data)
}
out <- lapply(ds, \(.ds){
rempsyc::nice_violin(
data = .ds,
group = y,
response = x, xtitle = get_label(data, var = y), ytitle = get_label(data, var = x)
)
})
wrap_plot_list(out)
# patchwork::wrap_plots(out,guides = "collect")
}