updated docs

This commit is contained in:
Andreas Gammelgaard Damsbo 2025-02-19 13:17:16 +01:00
parent c2b4b34215
commit c4b5a7ba79
No known key found for this signature in database
21 changed files with 444 additions and 80 deletions

View file

@ -1,14 +1,19 @@
# Generated by roxygen2: do not edit by hand
S3method(cut,hms)
S3method(plot,tbl_regression)
export(add_class_icon)
export(add_sparkline)
export(argsstring2list)
export(baseline_table)
export(clean_date)
export(clean_sep)
export(create_overview_datagrid)
export(custom_theme)
export(cut_variable_server)
export(cut_variable_ui)
export(data_correlations_server)
export(data_correlations_ui)
export(data_summary_server)
export(data_summary_ui)
export(default_format_arguments)
@ -16,24 +21,35 @@ export(default_parsing)
export(factorize)
export(file_export)
export(format_writer)
export(get_fun_options)
export(getfun)
export(gg_theme_export)
export(gg_theme_shiny)
export(index_embed)
export(is_any_class)
export(is_consecutive)
export(is_datetime)
export(launch)
export(m_datafileUI)
export(m_redcap_readServer)
export(m_redcap_readUI)
export(merge_long)
export(modal_cut_variable)
export(modify_qmd)
export(outcome_type)
export(overview_vars)
export(possible_functions)
export(read_input)
export(regression_model)
export(regression_model_list)
export(regression_model_uv)
export(regression_model_uv_list)
export(regression_table)
export(remove_empty_cols)
export(remove_na_attr)
export(shiny_freesearcheR)
export(specify_qmd_format)
export(supported_functions)
export(tbl_merge)
export(update_variables_server)
export(update_variables_ui)

View file

@ -6,7 +6,7 @@
#' @returns Shiny ui module
#' @export
data_correlations_ui <- function(id, ...) {
ns <- NS(id)
ns <- shiny::NS(id)
shiny::tagList(
shiny::textOutput(outputId = ns("suggest")),

View file

@ -13,6 +13,7 @@
#'
#' @return object of standard class for fun
#' @export
#' @rdname regression_model
#'
#' @examples
#' gtsummary::trial |>
@ -149,6 +150,7 @@ regression_model <- function(data,
#' @param ... ignored for now
#'
#' @importFrom stats as.formula
#' @rdname regression_model
#'
#' @return object of standard class for fun
#' @export
@ -323,7 +325,7 @@ supported_functions <- function() {
#'
#' @param data data
#'
#' @returns
#' @returns character vector
#' @export
#'
#' @examples
@ -412,8 +414,9 @@ get_fun_options <- function(data) {
#' argsstring2list() or list of arguments. Default is NULL.
#' @param ... ignored
#'
#' @returns
#' @returns list
#' @export
#' @rdname regression_model
#'
#' @examples
#' \dontrun{
@ -528,19 +531,9 @@ list2str <- function(data) {
}
#' Title
#'
#' @param data
#' @param outcome.str
#' @param fun.descr
#' @param fun
#' @param formula.str
#' @param args.list
#' @param vars
#' @param ...
#'
#' @returns list
#' @export
#' @rdname regression_model
#'
#' @examples
#' \dontrun{

View file

@ -23,3 +23,15 @@ shiny_freesearcheR <- function(...) {
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 <- function(...){
shiny_freesearcheR(...)
}

17
man/clean_date.Rd Normal file
View file

@ -0,0 +1,17 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/update-variables-ext.R
\name{clean_date}
\alias{clean_date}
\title{Attempts at applying uniform date format}
\usage{
clean_date(data)
}
\arguments{
\item{data}{character string vector of possible dates}
}
\value{
character string
}
\description{
Attempts at applying uniform date format
}

21
man/clean_sep.Rd Normal file
View file

@ -0,0 +1,21 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/update-variables-ext.R
\name{clean_sep}
\alias{clean_sep}
\title{gsub wrapper for piping with default values for separator substituting}
\usage{
clean_sep(data, old.sep = "[-.,/]", new.sep = "-")
}
\arguments{
\item{data}{character vector}
\item{old.sep}{old separator}
\item{new.sep}{new separator}
}
\value{
character vector
}
\description{
gsub wrapper for piping with default values for separator substituting
}

31
man/data-correlations.Rd Normal file
View file

@ -0,0 +1,31 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/correlations-module.R
\name{data-correlations}
\alias{data-correlations}
\alias{data_correlations_ui}
\alias{data_correlations_server}
\title{Data correlations evaluation module}
\usage{
data_correlations_ui(id, ...)
data_correlations_server(id, data, include.class = NULL, cutoff = 0.7, ...)
}
\arguments{
\item{id}{Module id. (Use 'ns("id")')}
\item{...}{arguments passed to toastui::datagrid}
\item{data}{data}
\item{color.main}{main color}
\item{color.sec}{secondary color}
}
\value{
Shiny ui module
shiny server module
}
\description{
Data correlations evaluation module
}

View file

@ -8,16 +8,18 @@
\usage{
data_summary_ui(id)
data_summary_server(id, data, color.main, color.sec)
data_summary_server(id, data, color.main, color.sec, ...)
}
\arguments{
\item{id}{id}
\item{id}{Module id. (Use 'ns("id")')}
\item{data}{data}
\item{color.main}{main color}
\item{color.sec}{secondary color}
\item{...}{arguments passed to toastui::datagrid}
}
\value{
Shiny ui module

27
man/get_fun_options.Rd Normal file
View file

@ -0,0 +1,27 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/regression_model.R
\name{get_fun_options}
\alias{get_fun_options}
\title{Get the function options based on the selected function description}
\usage{
get_fun_options(data)
}
\arguments{
\item{data}{vector}
}
\value{
list
}
\description{
Get the function options based on the selected function description
}
\examples{
mtcars |>
default_parsing() |>
dplyr::pull(mpg) |>
possible_functions(design = "cross-sectional") |>
(\(.x){
.x[[1]]
})() |>
get_fun_options()
}

17
man/gg_theme_export.Rd Normal file
View file

@ -0,0 +1,17 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/theme.R
\name{gg_theme_export}
\alias{gg_theme_export}
\title{GGplot default theme for plotting export objects}
\usage{
gg_theme_export()
}
\arguments{
\item{data}{ggplot object}
}
\value{
ggplot object
}
\description{
GGplot default theme for plotting export objects
}

17
man/gg_theme_shiny.Rd Normal file
View file

@ -0,0 +1,17 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/theme.R
\name{gg_theme_shiny}
\alias{gg_theme_shiny}
\title{GGplot default theme for plotting in Shiny}
\usage{
gg_theme_shiny()
}
\arguments{
\item{data}{ggplot object}
}
\value{
ggplot object
}
\description{
GGplot default theme for plotting in Shiny
}

17
man/launch.Rd Normal file
View file

@ -0,0 +1,17 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/shiny_freesearcheR.R
\name{launch}
\alias{launch}
\title{Easily launch the freesearcheR app}
\usage{
launch(...)
}
\arguments{
\item{...}{passed on to \code{shiny::runApp()}}
}
\value{
shiny app
}
\description{
Easily launch the freesearcheR app
}

19
man/merge_long.Rd Normal file
View file

@ -0,0 +1,19 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/regression_plot.R
\name{merge_long}
\alias{merge_long}
\title{Wrapper to pivot gtsummary table data to long for plotting}
\usage{
merge_long(list, model.names)
}
\arguments{
\item{list}{a custom regression models list}
\item{model.names}{names of models to include}
}
\value{
list
}
\description{
Wrapper to pivot gtsummary table data to long for plotting
}

22
man/outcome_type.Rd Normal file
View file

@ -0,0 +1,22 @@
% 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)
}

View file

@ -0,0 +1,29 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/regression_plot.R
\name{plot.tbl_regression}
\alias{plot.tbl_regression}
\title{Regression coef plot from gtsummary. Slightly modified to pass on arguments}
\usage{
\method{plot}{tbl_regression}(x, ...)
}
\arguments{
\item{x}{(\code{tbl_regression}, \code{tbl_uvregression})\cr
A 'tbl_regression' or 'tbl_uvregression' object}
\item{...}{arguments passed to \code{ggstats::ggcoef_plot(...)}}
}
\value{
ggplot object
}
\description{
Regression coef plot from gtsummary. Slightly modified to pass on arguments
}
\examples{
\dontrun{
mod <- lm(mpg ~ ., mtcars)
p <- mod |>
gtsummary::tbl_regression() |>
plot(colour = "variable")
}
}

28
man/possible_functions.Rd Normal file
View file

@ -0,0 +1,28 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/regression_model.R
\name{possible_functions}
\alias{possible_functions}
\title{Get possible regression models}
\usage{
possible_functions(data, design = c("cross-sectional"))
}
\arguments{
\item{data}{data}
}
\value{
character vector
}
\description{
Get possible regression models
}
\examples{
mtcars |>
default_parsing() |>
dplyr::pull("cyl") |>
possible_functions(design = "cross-sectional")
mtcars |>
default_parsing() |>
dplyr::select("cyl") |>
possible_functions(design = "cross-sectional")
}

View file

@ -2,41 +2,85 @@
% Please edit documentation in R/regression_model.R
\name{regression_model}
\alias{regression_model}
\alias{regression_model_uv}
\alias{regression_model_list}
\alias{regression_model_uv_list}
\title{Create a regression model programatically}
\usage{
regression_model(
data,
outcome.str,
auto.mode = TRUE,
auto.mode = FALSE,
formula.str = NULL,
args.list = NULL,
fun = NULL,
vars = NULL,
...
)
regression_model_uv(
data,
outcome.str,
args.list = NULL,
fun = NULL,
vars = NULL,
...
)
regression_model_list(
data,
outcome.str,
fun.descr,
fun = NULL,
formula.str = NULL,
args.list = NULL,
vars = NULL,
...
)
regression_model_uv_list(
data,
outcome.str,
fun.descr,
fun = NULL,
formula.str = NULL,
args.list = NULL,
vars = NULL,
...
)
}
\arguments{
\item{data}{data set}
\item{data}{data}
\item{outcome.str}{Name of outcome variable. Character vector.}
\item{outcome.str}{name of outcome variable}
\item{auto.mode}{Make assumptions on function dependent on outcome data format. Overwrites other arguments.}
\item{formula.str}{Formula as string. Passed through 'glue::glue'. If given, 'outcome.str' and 'vars' are ignored. Optional.}
\item{formula.str}{custom formula glue string. Default is NULL.}
\item{args.list}{List of arguments passed to 'fun' with 'do.call'.}
\item{args.list}{custom character string to be converted using
argsstring2list() or list of arguments. Default is NULL.}
\item{fun}{Name of function as character vector or function to use for model creation.}
\item{fun}{name of custom function. Default is NULL.}
\item{vars}{character vector of variables to include}
\item{...}{ignored for now}
\item{...}{ignored}
\item{fun.descr}{Description of chosen function matching description in
"supported_functions()"}
}
\value{
object of standard class for fun
object of standard class for fun
list
list
}
\description{
Create a regression model programatically
Output is a concatenated list of model information and model
}
\examples{
gtsummary::trial |>
@ -49,10 +93,73 @@ gtsummary::trial |>
formula.str = "{outcome.str}~.",
args.list = NULL
)
gtsummary::trial |> regression_model(
gtsummary::trial |>
default_parsing() |>
regression_model(
outcome.str = "trt",
auto.mode = FALSE,
fun = "stats::glm",
args.list = list(family = binomial(link = "logit"))
)
m <- mtcars |>
default_parsing() |>
regression_model(
outcome.str = "mpg",
auto.mode = FALSE,
fun = "stats::lm",
formula.str = "{outcome.str}~{paste(vars,collapse='+')}",
args.list = NULL,
vars = c("mpg", "cyl")
)
broom::tidy(m)
\dontrun{
gtsummary::trial |>
regression_model_uv(outcome.str = "age")
gtsummary::trial |>
regression_model_uv(
outcome.str = "age",
fun = "stats::lm",
args.list = NULL
)
m <- gtsummary::trial |> regression_model_uv(
outcome.str = "trt",
auto.mode = FALSE,
fun = "stats::glm",
args.list = list(family = binomial(link = "logit"))
args.list = list(family = stats::binomial(link = "logit"))
)
lapply(m,broom::tidy) |> dplyr::bind_rows()
}
\dontrun{
gtsummary::trial |>
regression_model(
outcome.str = "age",
fun = "stats::lm",
formula.str = "{outcome.str}~.",
args.list = NULL
)
ls <- regression_model_list(data = default_parsing(mtcars), outcome.str = "cyl", fun.descr = "Ordinal logistic regression model")
summary(ls$model)
ls <- regression_model_list(data = default_parsing(gtsummary::trial), outcome.str = "trt", fun.descr = "Logistic regression model")
tbl <- gtsummary::tbl_regression(ls$model, exponentiate = TRUE)
m <- gtsummary::trial |>
default_parsing() |>
regression_model(
outcome.str = "trt",
fun = "stats::glm",
formula.str = "{outcome.str}~.",
args.list = list(family = stats::binomial(link = "logit"))
)
tbl2 <- gtsummary::tbl_regression(m, exponentiate = TRUE)
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()
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()
}
}

View file

@ -1,51 +0,0 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/regression_model.R
\name{regression_model_uv}
\alias{regression_model_uv}
\title{Create a regression model programatically}
\usage{
regression_model_uv(
data,
outcome.str,
args.list = NULL,
fun = NULL,
vars = NULL,
...
)
}
\arguments{
\item{data}{data set}
\item{outcome.str}{Name of outcome variable. Character vector.}
\item{args.list}{List of arguments passed to 'fun' with 'do.call'.}
\item{fun}{Name of function as character vector or function to use for model creation.}
\item{vars}{character vector of variables to include}
\item{...}{ignored for now}
}
\value{
object of standard class for fun
}
\description{
Create a regression model programatically
}
\examples{
\dontrun{
gtsummary::trial |>
regression_model_uv(outcome.str = "age")
gtsummary::trial |>
regression_model_uv(
outcome.str = "age",
fun = "stats::lm",
args.list = NULL
)
gtsummary::trial |> regression_model_uv(
outcome.str = "trt",
fun = "stats::glm",
args.list = list(family = stats::binomial(link = "logit"))
)
}
}

View file

@ -23,7 +23,7 @@ Create table of regression model
}
\examples{
\dontrun{
gtsummary::trial |>
tbl <- gtsummary::trial |>
regression_model(
outcome.str = "stage",
fun = "MASS::polr"
@ -36,7 +36,7 @@ gtsummary::trial |>
formula.str = "{outcome.str}~.",
args.list = NULL
) |>
regression_table()
regression_table() |> plot()
gtsummary::trial |>
regression_model(
outcome.str = "trt",

22
man/remove_empty_cols.Rd Normal file
View file

@ -0,0 +1,22 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/helpers.R
\name{remove_empty_cols}
\alias{remove_empty_cols}
\title{Removes columns with completenes below cutoff}
\usage{
remove_empty_cols(data, cutoff = 0.7)
}
\arguments{
\item{data}{data frame}
\item{cutoff}{numeric}
}
\value{
data frame
}
\description{
Removes columns with completenes below cutoff
}
\examples{
data.frame(a=1:10,b=NA, c=c(2,NA)) |> remove_empty_cols(cutoff=.5)
}

View file

@ -0,0 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/regression_model.R
\name{supported_functions}
\alias{supported_functions}
\title{Implemented functions}
\usage{
supported_functions()
}
\value{
list
}
\description{
Library of supported functions. The list name and "descr" element should be
unique for each element on list.
}
\examples{
supported_functions()
}