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
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)
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
13995display.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