From e9422a418b05f560a113896504215d6e04833791 Mon Sep 17 00:00:00 2001 From: Andreas Gammelgaard Damsbo Date: Mon, 24 Mar 2025 14:43:50 +0100 Subject: [PATCH] docs --- NAMESPACE | 8 +++++++- R/plot_box.R | 2 +- R/regression_plot.R | 2 +- man/append_list.Rd | 6 +++--- man/clean_common_axis.Rd | 19 +++++++++++++++++++ man/create_baseline.Rd | 28 ++++++++++++++++++++++++++++ man/create_log_tics.Rd | 20 ++++++++++++++++++++ man/data-plots.Rd | 23 +++++++++++++++++++++-- man/data_description.Rd | 23 +++++++++++++++++++++++ man/data_type.Rd | 27 +++++++++++++++++++++++++++ man/limit_log.Rd | 8 ++++---- man/missing_fraction.Rd | 2 +- man/outcome_type.Rd | 22 ---------------------- man/regression_model.Rd | 19 +++++++++++-------- man/remove_empty_cols.Rd | 2 +- man/remove_na_attr.Rd | 6 ++++-- man/subset_types.Rd | 4 ++-- 17 files changed, 173 insertions(+), 48 deletions(-) create mode 100644 man/clean_common_axis.Rd create mode 100644 man/create_baseline.Rd create mode 100644 man/create_log_tics.Rd create mode 100644 man/data_description.Rd create mode 100644 man/data_type.Rd delete mode 100644 man/outcome_type.Rd diff --git a/NAMESPACE b/NAMESPACE index aa34d84..9480d52 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,10 +9,13 @@ export(allign_axes) export(append_list) export(argsstring2list) export(baseline_table) +export(clean_common_axis) export(clean_date) export(clean_sep) export(columnSelectInput) export(contrast_text) +export(create_baseline) +export(create_log_tics) export(create_overview_datagrid) export(create_plot) export(custom_theme) @@ -20,8 +23,10 @@ export(cut_variable_server) export(cut_variable_ui) export(data_correlations_server) export(data_correlations_ui) +export(data_description) export(data_summary_server) export(data_summary_ui) +export(data_type) export(data_visuals_server) export(data_visuals_ui) export(default_format_arguments) @@ -61,8 +66,9 @@ export(missing_fraction) export(modal_cut_variable) export(modal_update_factor) export(modify_qmd) -export(outcome_type) export(overview_vars) +export(plot_box) +export(plot_box_single) export(plot_euler) export(plot_euler_single) export(plot_hbars) diff --git a/R/plot_box.R b/R/plot_box.R index 97f88f7..09ab6c8 100644 --- a/R/plot_box.R +++ b/R/plot_box.R @@ -36,7 +36,7 @@ plot_box <- function(data, x, y, z = NULL) { #' #' @name data-plots #' -#' @returns +#' @returns ggplot object #' @export #' #' @examples diff --git a/R/regression_plot.R b/R/regression_plot.R index 252e1ec..a21a4bf 100644 --- a/R/regression_plot.R +++ b/R/regression_plot.R @@ -123,7 +123,7 @@ limit_log <- function(data, fun, ...) { #' #' @param data numeric vector #' -#' @returns +#' @returns numeric vector #' @export #' #' @examples diff --git a/man/append_list.Rd b/man/append_list.Rd index 990f3a6..880daa0 100644 --- a/man/append_list.Rd +++ b/man/append_list.Rd @@ -20,8 +20,8 @@ list Append list with named index } \examples{ -ls_d <- list(test=c(1:20)) +ls_d <- list(test = c(1:20)) ls_d <- list() -data.frame(letters[1:20],1:20) |> append_list(ls_d,"letters") -letters[1:20]|> append_list(ls_d,"letters") +data.frame(letters[1:20], 1:20) |> append_list(ls_d, "letters") +letters[1:20] |> append_list(ls_d, "letters") } diff --git a/man/clean_common_axis.Rd b/man/clean_common_axis.Rd new file mode 100644 index 0000000..175053c --- /dev/null +++ b/man/clean_common_axis.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data_plots.R +\name{clean_common_axis} +\alias{clean_common_axis} +\title{Extract and clean axis ranges} +\usage{ +clean_common_axis(p, axis) +} +\arguments{ +\item{p}{plot} + +\item{axis}{axis. x or y.} +} +\value{ +vector +} +\description{ +Extract and clean axis ranges +} diff --git a/man/create_baseline.Rd b/man/create_baseline.Rd new file mode 100644 index 0000000..82e6fe1 --- /dev/null +++ b/man/create_baseline.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/baseline_table.R +\name{create_baseline} +\alias{create_baseline} +\title{Create a baseline table} +\usage{ +create_baseline(data, ..., by.var, add.p = FALSE, add.overall = FALSE) +} +\arguments{ +\item{data}{data} + +\item{...}{passed as fun.arg to baseline_table()} + +\item{add.p}{add comparison/p-value} + +\item{add.overall}{add overall column} + +\item{strat.var}{grouping/strat variable} +} +\value{ +gtsummary table list object +} +\description{ +Create a baseline table +} +\examples{ +mtcars |> create_baseline(by.var = "gear", add.p="yes"=="yes") +} diff --git a/man/create_log_tics.Rd b/man/create_log_tics.Rd new file mode 100644 index 0000000..9baf394 --- /dev/null +++ b/man/create_log_tics.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/regression_plot.R +\name{create_log_tics} +\alias{create_log_tics} +\title{Create summetric log ticks} +\usage{ +create_log_tics(data) +} +\arguments{ +\item{data}{numeric vector} +} +\value{ +numeric vector +} +\description{ +Create summetric log ticks +} +\examples{ +c(sample(seq(.1, 1, .1), 3), sample(1:10, 3)) |> create_log_tics() +} diff --git a/man/data-plots.Rd b/man/data-plots.Rd index 539381f..f580b0e 100644 --- a/man/data-plots.Rd +++ b/man/data-plots.Rd @@ -1,11 +1,13 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data_plots.R, R/plot_hbar.R, R/plot_ridge.R, -% R/plot_sankey.R, R/plot_scatter.R, R/plot_violin.R +% Please edit documentation in R/data_plots.R, R/plot_box.R, R/plot_hbar.R, +% R/plot_ridge.R, R/plot_sankey.R, R/plot_scatter.R, R/plot_violin.R \name{data-plots} \alias{data-plots} \alias{data_visuals_ui} \alias{data_visuals_server} \alias{create_plot} +\alias{plot_box} +\alias{plot_box_single} \alias{plot_hbars} \alias{plot_ridge} \alias{sankey_ready} @@ -20,6 +22,10 @@ data_visuals_server(id, data, ...) create_plot(data, type, x, y, z = NULL, ...) +plot_box(data, x, y, z = NULL) + +plot_box_single(data, x, y = NULL, seed = 2103) + plot_hbars(data, x, y, z = NULL) plot_ridge(data, x, y, z = NULL, ...) @@ -56,6 +62,10 @@ ggplot2 object ggplot2 object +ggplot object + +ggplot2 object + ggplot2 object data.frame @@ -71,6 +81,10 @@ Data correlations evaluation module Wrapper to create plot based on provided type +Beautiful box plot(s) + +Create nice box-plots + Nice horizontal stacked bars (Grotta bars) Plot nice ridge plot @@ -85,6 +99,11 @@ Beatiful violin plot } \examples{ create_plot(mtcars, "plot_violin", "mpg", "cyl") +mtcars |> plot_box(x = "mpg", y = "cyl", z = "gear") +mtcars |> + default_parsing() |> + plot_box(x = "mpg", y = "cyl", z = "gear") +mtcars |> plot_box_single("mpg","cyl") mtcars |> plot_hbars(x = "carb", y = "cyl") mtcars |> plot_hbars(x = "carb", y = NULL) mtcars |> diff --git a/man/data_description.Rd b/man/data_description.Rd new file mode 100644 index 0000000..97a0b0d --- /dev/null +++ b/man/data_description.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helpers.R +\name{data_description} +\alias{data_description} +\title{Ultra short data dascription} +\usage{ +data_description(data) +} +\arguments{ +\item{data}{} +} +\value{ +character vector +} +\description{ +Ultra short data dascription +} +\examples{ +data.frame( + sample(1:8, 20, TRUE), + sample(c(1:8, NA), 20, TRUE) +) |> data_description() +} diff --git a/man/data_type.Rd b/man/data_type.Rd new file mode 100644 index 0000000..af3716a --- /dev/null +++ b/man/data_type.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/regression_model.R +\name{data_type} +\alias{data_type} +\title{Data type assessment} +\usage{ +data_type(data) +} +\arguments{ +\item{data}{data} +} +\value{ +outcome type +} +\description{ +Data type assessment +} +\examples{ +mtcars |> + default_parsing() |> + lapply(data_type) +c(1, 2) |> data_type() +1 |> data_type() +c(rep(NA, 10)) |> data_type() +sample(1:100, 50) |> data_type() +factor(letters[1:20]) |> data_type() +} diff --git a/man/limit_log.Rd b/man/limit_log.Rd index 55bcf3c..9504060 100644 --- a/man/limit_log.Rd +++ b/man/limit_log.Rd @@ -20,8 +20,8 @@ numeric vector 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) +limit_log(-.1, floor) +limit_log(.1, ceiling) +limit_log(-2.1, ceiling) +limit_log(2.1, ceiling) } diff --git a/man/missing_fraction.Rd b/man/missing_fraction.Rd index 6182c2a..b3acab9 100644 --- a/man/missing_fraction.Rd +++ b/man/missing_fraction.Rd @@ -16,5 +16,5 @@ numeric vector Get missingsness fraction } \examples{ -c(NA,1:10,rep(NA,3)) |> missing_fraction() +c(NA, 1:10, rep(NA, 3)) |> missing_fraction() } diff --git a/man/outcome_type.Rd b/man/outcome_type.Rd deleted file mode 100644 index 6a674da..0000000 --- a/man/outcome_type.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/regression_model.R -\name{outcome_type} -\alias{outcome_type} -\title{Outcome data type assessment} -\usage{ -outcome_type(data) -} -\arguments{ -\item{data}{data} -} -\value{ -outcome type -} -\description{ -Outcome data type assessment -} -\examples{ -mtcars |> - default_parsing() |> - lapply(outcome_type) -} diff --git a/man/regression_model.Rd b/man/regression_model.Rd index 049e24d..d86453b 100644 --- a/man/regression_model.Rd +++ b/man/regression_model.Rd @@ -111,7 +111,7 @@ m <- mtcars |> args.list = NULL, vars = c("mpg", "cyl") ) - broom::tidy(m) +broom::tidy(m) \dontrun{ gtsummary::trial |> regression_model_uv(outcome.str = "age") @@ -126,7 +126,7 @@ m <- gtsummary::trial |> regression_model_uv( fun = "stats::glm", args.list = list(family = stats::binomial(link = "logit")) ) -lapply(m,broom::tidy) |> dplyr::bind_rows() +lapply(m, broom::tidy) |> dplyr::bind_rows() } \dontrun{ gtsummary::trial |> @@ -154,12 +154,15 @@ broom::tidy(ls$model) broom::tidy(m) } \dontrun{ -gtsummary::trial |> regression_model_uv( - outcome.str = "trt", - fun = "stats::glm", - args.list = list(family = stats::binomial(link = "logit")) -) |> lapply(broom::tidy) |> dplyr::bind_rows() +gtsummary::trial |> + regression_model_uv( + outcome.str = "trt", + fun = "stats::glm", + args.list = list(family = stats::binomial(link = "logit")) + ) |> + lapply(broom::tidy) |> + dplyr::bind_rows() ms <- regression_model_uv_list(data = default_parsing(mtcars), outcome.str = "mpg", fun.descr = "Linear regression model") -lapply(ms$model,broom::tidy) |> dplyr::bind_rows() +lapply(ms$model, broom::tidy) |> dplyr::bind_rows() } } diff --git a/man/remove_empty_cols.Rd b/man/remove_empty_cols.Rd index 690a7c9..48f9699 100644 --- a/man/remove_empty_cols.Rd +++ b/man/remove_empty_cols.Rd @@ -18,5 +18,5 @@ data frame Removes columns with completenes below cutoff } \examples{ -data.frame(a=1:10,b=NA, c=c(2,NA)) |> remove_empty_cols(cutoff=.5) +data.frame(a = 1:10, b = NA, c = c(2, NA)) |> remove_empty_cols(cutoff = .5) } diff --git a/man/remove_na_attr.Rd b/man/remove_na_attr.Rd index e5e01f8..41bb4ee 100644 --- a/man/remove_na_attr.Rd +++ b/man/remove_na_attr.Rd @@ -16,6 +16,8 @@ data.frame Remove NA labels } \examples{ -ds <- mtcars |> lapply(\(.x) REDCapCAST::set_attr(.x,label=NA,attr = "label")) -ds |> remove_na_attr() |> str() +ds <- mtcars |> lapply(\(.x) REDCapCAST::set_attr(.x, label = NA, attr = "label")) +ds |> + remove_na_attr() |> + str() } diff --git a/man/subset_types.Rd b/man/subset_types.Rd index bd01efe..7b3f366 100644 --- a/man/subset_types.Rd +++ b/man/subset_types.Rd @@ -4,7 +4,7 @@ \alias{subset_types} \title{Easily subset by data type function} \usage{ -subset_types(data, types, type.fun = outcome_type) +subset_types(data, types, type.fun = data_type) } \arguments{ \item{data}{data} @@ -21,6 +21,6 @@ Easily subset by data type function } \examples{ default_parsing(mtcars) |> subset_types("ordinal") -default_parsing(mtcars) |> subset_types(c("dichotomous", "ordinal")) +default_parsing(mtcars) |> subset_types(c("dichotomous", "ordinal" ,"categorical")) #' default_parsing(mtcars) |> subset_types("factor",class) }