Skip to content

Commit

Permalink
global options for nearly all arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Dec 11, 2024
1 parent 0096278 commit 5d50519
Show file tree
Hide file tree
Showing 20 changed files with 204 additions and 202 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Description: Create beautiful and customizable tables to summarize several
RTF, JPG, or PNG. Tables can easily be embedded in 'Rmarkdown' or 'knitr'
dynamic documents. Details can be found in Arel-Bundock (2022)
<doi:10.18637/jss.v103.i01>.
Version: 2.2.0.4
Version: 2.2.0.5
Authors@R: c(person("Vincent", "Arel-Bundock",
email = "[email protected]",
role = c("aut", "cre", "cph"),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Bugs:

New features:

* Nearly all arguments can now be set using global options.
* Support for variable labels supplied by the `labelled` and `sjlabelled` packages.

## 2.2.0
Expand Down
16 changes: 8 additions & 8 deletions R/datasummary.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@
#' @export
datasummary <- function(formula,
data,
output = "default",
output = getOption("modelsummary_output", default = "default"),
fmt = 2,
title = NULL,
notes = NULL,
align = NULL,
add_columns = NULL,
add_rows = NULL,
sparse_header = TRUE,
escape = TRUE,
title = getOption("modelsummary_title", default = NULL),
notes = getOption("modelsummary_notes", default = NULL),
align = getOption("modelsummary_align", default = NULL),
add_columns = getOption("modelsummary_add_columns", default = NULL),
add_rows = getOption("modelsummary_add_rows", default = NULL),
sparse_header = getOption("modelsummary_sparse_header", default = TRUE),
escape = getOption("modelsummary_escape", default = TRUE),
...) {
if (!isTRUE(list(...)[["internal_call"]])) {
## settings: don't overwrite settings on internal calls
Expand Down
20 changes: 10 additions & 10 deletions R/datasummary_balance.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
#' ```
datasummary_balance <- function(formula,
data,
output = "default",
output = getOption("modelsummary_output", default = "default"),
fmt = fmt_decimal(digits = 1, pdigits = 3),
title = NULL,
notes = NULL,
align = NULL,
stars = FALSE,
add_columns = NULL,
add_rows = NULL,
dinm = TRUE,
dinm_statistic = "std.error",
escape = TRUE,
title = getOption("modelsummary_title", default = NULL),
notes = getOption("modelsummary_notes", default = NULL),
align = getOption("modelsummary_align", default = NULL),
stars = getOption("modelsummary_stars", default = FALSE),
add_columns = getOption("modelsummary_add_columns", default = NULL),
add_rows = getOption("modelsummary_add_rows", default = NULL),
dinm = getOption("modelsummary_dinm", default = TRUE),
dinm_statistic = getOption("modelsummary_dinm_statistic", default = "std.error"),
escape = getOption("modelsummary_escape", default = TRUE),
...) {
## settings
settings_init(settings = list("function_called" = "datasummary_balance"))
Expand Down
18 changes: 9 additions & 9 deletions R/datasummary_correlation.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@
#' datasummary_correlation(dat, method = cor_fun, escape = FALSE)
#' ```
datasummary_correlation <- function(data,
output = "default",
method = "pearson",
output = getOption("modelsummary_output", default = "default"),
method = getOption("modelsummary_method", default = "pearson"),
fmt = 2,
align = NULL,
add_rows = NULL,
add_columns = NULL,
title = NULL,
notes = NULL,
escape = TRUE,
stars = FALSE,
align = getOption("modelsummary_align", default = NULL),
add_rows = getOption("modelsummary_add_rows", default = NULL),
add_columns = getOption("modelsummary_add_columns", default = NULL),
title = getOption("modelsummary_title", default = NULL),
notes = getOption("modelsummary_notes", default = NULL),
escape = getOption("modelsummary_escape", default = TRUE),
stars = getOption("modelsummary_stars", default = FALSE),
...) {
## settings
settings_init(settings = list(
Expand Down
16 changes: 8 additions & 8 deletions R/datasummary_crosstab.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@
datasummary_crosstab <- function(formula,
statistic = 1 ~ 1 + N + Percent("row"),
data,
output = "default",
output = getOption("modelsummary_output", default = "default"),
fmt = 1,
title = NULL,
notes = NULL,
align = NULL,
add_columns = NULL,
add_rows = NULL,
sparse_header = TRUE,
escape = TRUE,
title = getOption("modelsummary_title", default = NULL),
notes = getOption("modelsummary_notes", default = NULL),
align = getOption("modelsummary_align", default = NULL),
add_columns = getOption("modelsummary_add_columns", default = NULL),
add_rows = getOption("modelsummary_add_rows", default = NULL),
sparse_header = getOption("modelsummary_sparse_header", default = TRUE),
escape = getOption("modelsummary_escape", default = TRUE),
...) {
## settings
settings_init(settings = list(
Expand Down
20 changes: 10 additions & 10 deletions R/datasummary_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
#' @template citation
#' @export
datasummary_df <- function(data,
output = "default",
fmt = 2,
align = NULL,
hrule = NULL,
title = NULL,
notes = NULL,
add_rows = NULL,
add_columns = NULL,
escape = TRUE,
...) {
output = getOption("modelsummary_output", default = "default"),
fmt = 2,
align = getOption("modelsummary_align", default = NULL),
hrule = getOption("modelsummary_hrule", default = NULL),
title = getOption("modelsummary_title", default = NULL),
notes = getOption("modelsummary_notes", default = NULL),
add_rows = getOption("modelsummary_add_rows", default = NULL),
add_columns = getOption("modelsummary_add_columns", default = NULL),
escape = getOption("modelsummary_escape", default = TRUE),
...) {
settings_init(settings = list("function_called" = "datasummary_df"))

tmp <- sanitize_output(output) # before sanitize_escape
Expand Down
18 changes: 9 additions & 9 deletions R/datasummary_skim.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@
#'
#' @export
datasummary_skim <- function(data,
output = "default",
type = "all",
output = getOption("modelsummary_output", default = "default"),
type = getOption("modelsummary_type", default = "all"),
fmt = 1,
title = NULL,
notes = NULL,
align = NULL,
escape = TRUE,
by = NULL,
fun_numeric = list(
title = getOption("modelsummary_title", default = NULL),
notes = getOption("modelsummary_notes", default = NULL),
align = getOption("modelsummary_align", default = NULL),
escape = getOption("modelsummary_escape", default = TRUE),
by = getOption("modelsummary_by", default = NULL),
fun_numeric = getOption("modelsummary_fun_numeric", default = list(
"Unique" = NUnique,
"Missing Pct." = PercentMissing,
"Mean" = Mean,
"SD" = SD,
"Min" = Min,
"Median" = Median,
"Max" = Max,
"Histogram" = function(x) ""),
"Histogram" = function(x) "")),
...) {
## settings
settings_init(settings = list("function_called" = "datasummary_skim"))
Expand Down
22 changes: 11 additions & 11 deletions R/modelplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@
#'
#' @export
modelplot <- function(models,
conf_level = .95,
coef_map = NULL,
coef_omit = NULL,
coef_rename = NULL,
vcov = NULL,
exponentiate = FALSE,
add_rows = NULL,
facet = FALSE,
draw = TRUE,
background = NULL,
...) {
conf_level = getOption("modelsummary_conf_level", default = .95),
coef_map = getOption("modelsummary_coef_map", default = NULL),
coef_omit = getOption("modelsummary_coef_omit", default = NULL),
coef_rename = getOption("modelsummary_coef_rename", default = NULL),
vcov = getOption("modelsummary_vcov", default = NULL),
exponentiate = getOption("modelsummary_exponentiate", default = FALSE),
add_rows = getOption("modelsummary_add_rows", default = NULL),
facet = getOption("modelsummary_facet", default = FALSE),
draw = getOption("modelsummary_draw", default = TRUE),
background = getOption("modelsummary_background", default = NULL),
...) {

ellip <- list(...)

Expand Down
44 changes: 22 additions & 22 deletions R/modelsummary.R
Original file line number Diff line number Diff line change
Expand Up @@ -370,28 +370,28 @@ globalVariables(c(
#' @export
modelsummary <- function(
models,
output = "default",
fmt = 3,
estimate = "estimate",
statistic = "std.error",
vcov = NULL,
conf_level = 0.95,
exponentiate = FALSE,
stars = FALSE,
shape = term + statistic ~ model,
coef_map = NULL,
coef_omit = NULL,
coef_rename = FALSE,
gof_map = NULL,
gof_omit = NULL,
gof_function = NULL,
group_map = NULL,
add_columns = NULL,
add_rows = NULL,
align = NULL,
notes = NULL,
title = NULL,
escape = TRUE,
output = getOption("modelsummary_output", default = "default"),
fmt = getOption("modelsummary_fmt", default = 3),
estimate = getOption("modelsummary_estimate", default = "estimate"),
statistic = getOption("modelsummary_statistic", default = "std.error"),
vcov = getOption("modelsummary_vcov", default = NULL),
conf_level = getOption("modelsummary_conf_level", default = 0.95),
exponentiate = getOption("modelsummary_exponentiate", default = FALSE),
stars = getOption("modelsummary_stars", default = FALSE),
shape = getOption("modelsummary_shape", default = term + statistic ~ model),
coef_map = getOption("modelsummary_coef_map", default = NULL),
coef_omit = getOption("modelsummary_coef_omit", default = NULL),
coef_rename = getOption("modelsummary_coef_rename", default = FALSE),
gof_map = getOption("modelsummary_gof_map", default = NULL),
gof_omit = getOption("modelsummary_gof_omit", default = NULL),
gof_function = getOption("modelsummary_gof_function", default = NULL),
group_map = getOption("modelsummary_group_map", default = NULL),
add_columns = getOption("modelsummary_add_columns", default = NULL),
add_rows = getOption("modelsummary_add_rows", default = NULL),
align = getOption("modelsummary_align", default = NULL),
notes = getOption("modelsummary_notes", default = NULL),
title = getOption("modelsummary_title", default = NULL),
escape = getOption("modelsummary_escape", default = TRUE),
...) {
# panel summary shape: dispatch to other function
checkmate::assert(
Expand Down
16 changes: 8 additions & 8 deletions man/datasummary.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions man/datasummary_balance.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions man/datasummary_correlation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions man/datasummary_crosstab.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions man/datasummary_df.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5d50519

Please sign in to comment.