Skip to content

Commit 55c3745

Browse files
authored
Merge branch 'main' into strengejacke/issue1135
2 parents 0f130d2 + 1c8dea9 commit 55c3745

36 files changed

+1126
-1647
lines changed

DESCRIPTION

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: parameters
33
Title: Processing of Model Parameters
4-
Version: 0.27.0.1
4+
Version: 0.27.0.5
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",
@@ -202,6 +202,7 @@ Suggests:
202202
rms,
203203
rstan,
204204
rstanarm,
205+
sampleSelection,
205206
sandwich,
206207
see (>= 0.8.1),
207208
serp,
@@ -230,3 +231,4 @@ Config/testthat/parallel: true
230231
Config/Needs/website: easystats/easystatstemplate
231232
Config/Needs/check: stan-dev/cmdstanr
232233
Config/rcmdcheck/ignore-inconsequential-notes: true
234+
Remotes: easystats/insight

NAMESPACE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,12 @@ S3method(display,parameters_efa_summary)
128128
S3method(display,parameters_model)
129129
S3method(display,parameters_omega)
130130
S3method(display,parameters_omega_summary)
131+
S3method(display,parameters_p_function)
131132
S3method(display,parameters_pca)
132133
S3method(display,parameters_pca_summary)
133134
S3method(display,parameters_sem)
134135
S3method(display,parameters_simulate)
136+
S3method(display,parameters_standardized)
135137
S3method(dof_satterthwaite,lmerMod)
136138
S3method(equivalence_test,MixMod)
137139
S3method(equivalence_test,feis)
@@ -611,6 +613,7 @@ S3method(print,parameters_sem)
611613
S3method(print,parameters_simulate)
612614
S3method(print,parameters_standardized)
613615
S3method(print_html,compare_parameters)
616+
S3method(print_html,equivalence_test_lm)
614617
S3method(print_html,parameters_brms_meta)
615618
S3method(print_html,parameters_efa)
616619
S3method(print_html,parameters_efa_summary)
@@ -981,7 +984,6 @@ export(pool_parameters)
981984
export(principal_components)
982985
export(print_html)
983986
export(print_md)
984-
export(print_table)
985987
export(random_parameters)
986988
export(reduce_data)
987989
export(reduce_parameters)

NEWS.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
# parameters (devel)
2+
3+
## Breaking Changes
4+
5+
* The experimental `print_table()` function was removed. The aim of this function
6+
was to test the implementation of the `tinytable` backend for printing. Now,
7+
`tinytable` is fully supported by `insight::export_table()` and thereby also
8+
by the various `print()` resp. `display()` methods for model parameters.
9+
10+
## Changes
11+
12+
* All `print_html()` methods get an `engine` argument, to either use the `gt`
13+
package or the `tinytable` package for printing HTML tables. Since `tinytable`
14+
not only produces HTML tables, but rather different formats depending on the
15+
environment, `print_html()` may also generate a markdown table. Thus, the
16+
generic `display()` method can be used, too, which has a `format` argument that
17+
also supports `"tt"` for `tinytable`.
18+
19+
## Bug fixes
20+
21+
* Fixed issue with models of class `selection` with multiple outcomes.
22+
123
# parameters 0.27.0
224

325
## Breaking Changes

R/display.R

Lines changed: 50 additions & 199 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,24 @@
22
#' @name display.parameters_model
33
#'
44
#' @description Prints tables (i.e. data frame) in different output formats.
5-
#' `print_md()` is an alias for `display(format = "markdown")`, `print_html()`
6-
#' is an alias for `display(format = "html")`. `print_table()` is for specific
7-
#' use cases only, and currently only works for `compare_parameters()` objects.
5+
#' `print_md()` is an alias for `display(format = "markdown")` and
6+
#' `print_html()` is an alias for `display(format = "html")`. A third option is
7+
#' `display(format = "tt")`, which returns a `tinytable` object, which is either
8+
#' printed as markdown or HTML table, depending on the environment.
89
#'
9-
#' @param x An object returned by [`model_parameters()`].
10-
#' @param object An object returned by [`model_parameters()`],[`simulate_parameters()`],
11-
#' [`equivalence_test()`] or [`principal_components()`].
10+
#' @param object An object returned by one of the package's function, for example
11+
#' [`model_parameters()`], [`simulate_parameters()`], [`equivalence_test()`] or
12+
#' [`principal_components()`].
1213
#' @param format String, indicating the output format. Can be `"markdown"`
13-
#' or `"html"`.
14-
#' @param align Only applies to HTML tables. May be one of `"left"`,
15-
#' `"right"` or `"center"`.
16-
#' @param digits,ci_digits,p_digits Number of digits for rounding or
17-
#' significant figures. May also be `"signif"` to return significant
18-
#' figures or `"scientific"` to return scientific notation. Control the
19-
#' number of digits by adding the value as suffix, e.g. `digits = "scientific4"`
20-
#' to have scientific notation with 4 decimal places, or `digits = "signif5"`
21-
#' for 5 significant figures (see also [signif()]).
22-
#' @param subtitle Table title (same as caption) and subtitle, as strings. If `NULL`,
23-
#' no title or subtitle is printed, unless it is stored as attributes (`table_title`,
24-
#' or its alias `table_caption`, and `table_subtitle`). If `x` is a list of
25-
#' data frames, `caption` may be a list of table captions, one for each table.
26-
#' @param font_size For HTML tables, the font size.
27-
#' @param line_padding For HTML tables, the distance (in pixel) between lines.
28-
#' @param column_labels Labels of columns for HTML tables. If `NULL`, automatic
29-
#' column names are generated. See 'Examples'.
30-
#' @param theme String, indicating the table theme. Can be one of `"default"`,
31-
#' `"grid"`, `"striped"`, `"bootstrap"` or `"darklines"`.
32-
#' @inheritParams print.parameters_model
33-
#' @inheritParams insight::format_table
34-
#' @inheritParams insight::export_table
35-
#' @inheritParams compare_parameters
14+
#' `"html"`, or `"tt"`. `format = "tt"` creates a `tinytable` object, which is
15+
#' either printed as markdown or HTML table, depending on the environment. See
16+
#' [`insight::export_table()`] for details.
17+
#' @param ... Arguments passed to the underlying functions, such as `print_md()`
18+
#' or `print_html()`.
3619
#'
3720
#' @return If `format = "markdown"`, the return value will be a character
3821
#' vector in markdown-table format. If `format = "html"`, an object of
39-
#' class `gt_tbl`. For `print_table()`, an object of class `tinytable` is
40-
#' returned.
22+
#' class `gt_tbl`. If `format = "tt"`, an object of class `tinytable`.
4123
#'
4224
#' @details `display()` is useful when the table-output from functions,
4325
#' which is usually printed as formatted text-table to console, should
@@ -46,15 +28,7 @@
4628
#' [vignette](https://easystats.github.io/parameters/articles/model_parameters_formatting.html)
4729
#' for examples.
4830
#'
49-
#' `print_table()` is a special function for `compare_parameters()` objects,
50-
#' which prints the output as a formatted HTML table. It is still somewhat
51-
#' experimental, thus, only a fixed layout-style is available at the moment
52-
#' (columns for estimates, confidence intervals and p-values). However, it
53-
#' is possible to include other model components, like zero-inflation, or random
54-
#' effects in the table. See 'Examples'. An alternative is to set `engine = "tt"`
55-
#' in `print_html()` to use the _tinytable_ package for creating HTML tables.
56-
#'
57-
#' @seealso [print.parameters_model()] and [print.compare_parameters()]
31+
#' @seealso [`print.parameters_model()`] and [`print.compare_parameters()`]
5832
#'
5933
#' @examplesIf require("gt", quietly = TRUE)
6034
#' model <- lm(mpg ~ wt + cyl, data = mtcars)
@@ -81,54 +55,36 @@
8155
#' column_labels = c("Est. (95% CI)")
8256
#' )
8357
#' }
58+
#'
59+
#' @examplesIf all(insight::check_if_installed(c("glmmTMB", "lme4", "tinytable"), quietly = TRUE))
60+
#' \donttest{
61+
#' data(iris)
62+
#' data(Salamanders, package = "glmmTMB")
63+
#' m1 <- lm(Sepal.Length ~ Species * Petal.Length, data = iris)
64+
#' m2 <- lme4::lmer(
65+
#' Sepal.Length ~ Petal.Length + Petal.Width + (1 | Species),
66+
#' data = iris
67+
#' )
68+
#' m3 <- glmmTMB::glmmTMB(
69+
#' count ~ spp + mined + (1 | site),
70+
#' ziformula = ~mined,
71+
#' family = poisson(),
72+
#' data = Salamanders
73+
#' )
74+
#' out <- compare_parameters(m1, m2, m3, effects = "all", component = "all")
75+
#'
76+
#' display(out, format = "tt")
77+
#'
78+
#' display(out, select = "{estimate}|{ci}", format = "tt")
79+
#' }
8480
#' @export
85-
display.parameters_model <- function(object,
86-
format = "markdown",
87-
pretty_names = TRUE,
88-
split_components = TRUE,
89-
select = NULL,
90-
caption = NULL,
91-
subtitle = NULL,
92-
footer = NULL,
93-
align = NULL,
94-
digits = 2,
95-
ci_digits = digits,
96-
p_digits = 3,
97-
footer_digits = 3,
98-
ci_brackets = c("(", ")"),
99-
show_sigma = FALSE,
100-
show_formula = FALSE,
101-
zap_small = FALSE,
102-
font_size = "100%",
103-
line_padding = 4,
104-
column_labels = NULL,
105-
include_reference = FALSE,
106-
verbose = TRUE,
107-
...) {
81+
display.parameters_model <- function(object, format = "markdown", ...) {
10882
format <- insight::validate_argument(format, c("markdown", "html", "md", "tt"))
10983

110-
fun_args <- list(
111-
x = object, pretty_names = pretty_names, split_components = split_components,
112-
select = select, digits = digits, caption = caption, subtitle = subtitle,
113-
footer = footer, ci_digits = ci_digits, p_digits = p_digits,
114-
footer_digits = footer_digits, ci_brackets = ci_brackets,
115-
show_sigma = show_sigma, show_formula = show_formula, zap_small = zap_small,
116-
include_reference = include_reference, verbose = verbose
117-
)
118-
11984
if (format %in% c("html", "tt")) {
120-
fun_args <- c(
121-
fun_args,
122-
list(
123-
column_labels = column_labels,
124-
align = align,
125-
font_size = font_size,
126-
line_padding = line_padding
127-
)
128-
)
129-
do.call(print_html, c(fun_args, list(...)))
85+
print_html(x = object, backend = ifelse(format == "tt", "tt", "html"), ...)
13086
} else {
131-
do.call(print_md, c(fun_args, list(...)))
87+
print_md(x = object, ...)
13288
}
13389
}
13490

@@ -138,137 +94,32 @@ display.parameters_simulate <- display.parameters_model
13894
#' @export
13995
display.parameters_brms_meta <- display.parameters_model
14096

141-
142-
# Compare Parameters ------------------------
143-
144-
14597
#' @export
146-
display.compare_parameters <- function(object,
147-
format = "markdown",
148-
digits = 2,
149-
ci_digits = digits,
150-
p_digits = 3,
151-
select = NULL,
152-
column_labels = NULL,
153-
ci_brackets = c("(", ")"),
154-
font_size = "100%",
155-
line_padding = 4,
156-
zap_small = FALSE,
157-
...) {
158-
format <- insight::validate_argument(format, c("markdown", "html", "md", "tt"))
159-
160-
fun_args <- list(
161-
x = object,
162-
digits = digits,
163-
ci_digits = ci_digits,
164-
p_digits = p_digits,
165-
ci_brackets = ci_brackets,
166-
select = select,
167-
zap_small = zap_small
168-
)
169-
170-
if (format %in% c("html", "tt")) {
171-
fun_args <- c(
172-
fun_args,
173-
list(
174-
column_labels = column_labels,
175-
font_size = font_size,
176-
line_padding = line_padding
177-
)
178-
)
179-
do.call(print_html, c(fun_args, list(...)))
180-
} else {
181-
do.call(print_md, c(fun_args, list(...)))
182-
}
183-
}
98+
display.compare_parameters <- display.parameters_model
18499

185-
186-
# SEM models ------------------------
187-
188-
189-
#' @rdname display.parameters_model
190100
#' @export
191-
display.parameters_sem <- function(object,
192-
format = "markdown",
193-
digits = 2,
194-
ci_digits = digits,
195-
p_digits = 3,
196-
ci_brackets = c("(", ")"),
197-
...) {
198-
format <- insight::validate_argument(format, c("markdown", "html", "md", "tt"))
199-
200-
fun_args <- list(
201-
x = object,
202-
digits = digits,
203-
ci_digits = ci_digits,
204-
p_digits = p_digits,
205-
ci_brackets = ci_brackets
206-
)
101+
display.parameters_sem <- display.parameters_model
207102

208-
if (format %in% c("html", "tt")) {
209-
do.call(print_html, c(fun_args, list(...)))
210-
} else {
211-
do.call(print_md, c(fun_args, list(...)))
212-
}
213-
}
214-
215-
216-
# PCA /EFA models ------------------------
217-
218-
219-
#' @rdname display.parameters_model
220103
#' @export
221-
display.parameters_efa_summary <- function(object, format = "markdown", digits = 3, ...) {
222-
format <- insight::validate_argument(format, c("markdown", "html", "md", "tt"))
223-
fun_args <- list(x = object, digits = digits)
224-
225-
if (format %in% c("html", "tt")) {
226-
do.call(print_html, c(fun_args, list(...)))
227-
} else {
228-
do.call(print_md, c(fun_args, list(...)))
229-
}
230-
}
104+
display.parameters_efa_summary <- display.parameters_model
231105

232106
#' @export
233-
display.parameters_pca_summary <- display.parameters_efa_summary
107+
display.parameters_pca_summary <- display.parameters_model
234108

235109
#' @export
236-
display.parameters_omega_summary <- display.parameters_efa_summary
110+
display.parameters_omega_summary <- display.parameters_model
237111

238-
239-
#' @inheritParams model_parameters.principal
240-
#' @rdname display.parameters_model
241112
#' @export
242-
display.parameters_efa <- function(object, format = "markdown", digits = 2, sort = FALSE, threshold = NULL, labels = NULL, ...) {
243-
format <- insight::validate_argument(format, c("markdown", "html", "md", "tt"))
244-
245-
fun_args <- list(
246-
x = object,
247-
digits = digits,
248-
sort = sort,
249-
threshold = threshold,
250-
labels = labels
251-
)
252-
253-
if (format %in% c("html", "tt")) {
254-
do.call(print_html, c(fun_args, list(...)))
255-
} else {
256-
do.call(print_md, c(fun_args, list(...)))
257-
}
258-
}
113+
display.parameters_efa <- display.parameters_model
259114

260115
#' @export
261-
display.parameters_pca <- display.parameters_efa
116+
display.parameters_pca <- display.parameters_model
262117

263118
#' @export
264-
display.parameters_omega <- display.parameters_efa
265-
266-
267-
# Equivalence tests ------------------------
119+
display.parameters_omega <- display.parameters_model
268120

121+
#' @export
122+
display.equivalence_test_lm <- display.parameters_model
269123

270-
#' @rdname display.parameters_model
271124
#' @export
272-
display.equivalence_test_lm <- function(object, format = "markdown", digits = 2, ...) {
273-
print_md(x = object, digits = digits, ...)
274-
}
125+
display.parameters_p_function <- display.parameters_model

0 commit comments

Comments
 (0)