Initial commit

This commit is contained in:
Andreas Gammelgaard Damsbo 2024-11-08 15:13:33 +01:00
commit ccab72aa0f
31 changed files with 6547 additions and 0 deletions

32
man/baseline_table.Rd Normal file
View file

@ -0,0 +1,32 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/baseline_table.R
\name{baseline_table}
\alias{baseline_table}
\title{Print a flexible baseline characteristics table}
\usage{
baseline_table(
data,
fun.args = NULL,
fun = gtsummary::tbl_summary,
vars = NULL
)
}
\arguments{
\item{data}{data set}
\item{fun.args}{list of arguments passed to}
\item{fun}{function to}
\item{vars}{character vector of variables to include}
}
\value{
object of standard class for fun
}
\description{
Print a flexible baseline characteristics table
}
\examples{
mtcars |> baseline_table()
mtcars |> baseline_table(fun.args = list(by = "gear"))
}

21
man/file_extension.Rd Normal file
View file

@ -0,0 +1,21 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/helpers.R
\name{file_extension}
\alias{file_extension}
\title{Helper to import files correctly}
\usage{
file_extension(filenames)
}
\arguments{
\item{filenames}{file names}
}
\value{
character vector
}
\description{
Helper to import files correctly
}
\examples{
file_extension(list.files(here::here(""))[[2]])[[1]]
file_extension(c("file.cd..ks", "file"))
}

20
man/getfun.Rd Normal file
View file

@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/helpers.R
\name{getfun}
\alias{getfun}
\title{Wrapper function to get function from character vector referring to function from namespace. Passed to 'do.call()'}
\usage{
getfun(x)
}
\arguments{
\item{x}{function or function name}
}
\value{
function or character vector
}
\description{
This function follows the idea from this comment: https://stackoverflow.com/questions/38983179/do-call-a-function-in-r-without-loading-the-package
}
\examples{
getfun("stats::lm")
}

22
man/read_input.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{read_input}
\alias{read_input}
\title{Flexible file import based on extension}
\usage{
read_input(file, consider.na = c("NA", "\\"\\"", ""))
}
\arguments{
\item{file}{file name}
\item{consider.na}{character vector of strings to consider as NAs}
}
\value{
tibble
}
\description{
Flexible file import based on extension
}
\examples{
read_input("https://raw.githubusercontent.com/agdamsbo/cognitive.index.lookup/main/data/sample.csv")
}

54
man/regression_model.Rd Normal file
View file

@ -0,0 +1,54 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/regression_model.R
\name{regression_model}
\alias{regression_model}
\title{Print a flexible baseline characteristics table}
\usage{
regression_model(
data,
outcome.str = "gear",
outcome.factor = TRUE,
formula.str = NULL,
args.list = list(Hess = TRUE, method = "logistic"),
fun = "MASS::polr",
vars = NULL
)
}
\arguments{
\item{data}{data set}
\item{outcome.str}{Name of outcome variable. Character vector.}
\item{outcome.factor}{Factorize outcome variable. Logical.}
\item{formula.str}{Formula as string. Passed through 'glue::glue'. If given, 'outcome.str' and 'vars' are ignored. Optional.}
\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}
}
\value{
object of standard class for fun
}
\description{
Print a flexible baseline characteristics table
}
\examples{
gtsummary::trial |>
regression_model(outcome.str = "stage", fun = "MASS::polr")
gtsummary::trial |>
regression_model(
outcome.str = "age",
outcome.factor = FALSE,
fun = "stats::lm",
formula.str = "{outcome.str}~.",
args.list = NULL
)
gtsummary::trial |> regression_model(
outcome.str = "trt",
fun = "stats::glm",
args.list = list(family = binomial(link = "logit"))
)
}

45
man/regression_table.Rd Normal file
View file

@ -0,0 +1,45 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/regression_table.R
\name{regression_table}
\alias{regression_table}
\title{Create table of regression model}
\usage{
regression_table(data, args.list = NULL, fun = "gtsummary::tbl_regression")
}
\arguments{
\item{data}{regression model}
\item{args.list}{list of arguments passed to 'fun'.}
\item{fun}{function to use for table creation. Default is "gtsummary::tbl_regression".}
}
\value{
object of standard class for fun
}
\description{
Create table of regression model
}
\examples{
gtsummary::trial |>
regression_model(
outcome.str = "stage",
fun = "MASS::polr"
) |>
regression_table(args.list = list(exponentiate = TRUE))
gtsummary::trial |>
regression_model(
outcome.str = "age",
outcome.factor = FALSE,
fun = "stats::lm",
formula.str = "{outcome.str}~.",
args.list = NULL
) |>
regression_table()
gtsummary::trial |>
regression_model(
outcome.str = "trt",
fun = "stats::glm",
args.list = list(family = binomial(link = "logit"))
) |>
regression_table(args.list = list(exponentiate = TRUE))
}

31
man/write_quarto.Rd Normal file
View file

@ -0,0 +1,31 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/helpers.R
\name{write_quarto}
\alias{write_quarto}
\title{Wrapper to save data in RDS, load into specified qmd and render}
\usage{
write_quarto(
data,
fileformat,
qmd.file = here::here("analyses.qmd"),
file = NULL,
...
)
}
\arguments{
\item{data}{list to pass to qmd}
\item{fileformat}{output format. Ignored if file!=NULL}
\item{qmd.file}{qmd file to render. Default is 'here::here("analyses.qmd")'}
\item{file}{exact filename (Optional)}
\item{...}{Ignored for now}
}
\value{
none
}
\description{
Wrapper to save data in RDS, load into specified qmd and render
}