Skip to content

Commit b86d775

Browse files
committed
allow default option for display()
1 parent a3ae190 commit b86d775

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: performance
33
Title: Assessment of Regression Models Performance
4-
Version: 0.15.0.2
4+
Version: 0.15.0.3
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",

R/display.R

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
#' @param caption Table caption as string. If `NULL`, no table caption is printed.
1616
#' @param ... Currently not used.
1717
#'
18+
#' @section Global Options to Customize Output when Printing:
19+
#'
20+
#' - `easystats_display_format`: `options(easystats_display_format = <value>)`
21+
#' will set the default format for the `display()` methods. Can be one of
22+
#' `"markdown"`, `"html"`, or `"tt"`.
23+
#'
1824
#' @return A character vector. If `format = "markdown"`, the return value
1925
#' will be a character vector in markdown-table format.
2026
#'
@@ -31,7 +37,7 @@
3137
#' display(mp)
3238
#' @export
3339
display.performance_model <- function(object, format = "markdown", digits = 2, caption = NULL, ...) {
34-
format <- insight::validate_argument(format, c("markdown", "md", "html", "tt"))
40+
format <- .display_default_format(format)
3541
if (format %in% c("html", "tt")) {
3642
print_html(
3743
x = object,
@@ -62,3 +68,8 @@ display.item_omega <- display.performance_model
6268

6369
#' @export
6470
display.item_difficulty <- display.performance_model
71+
72+
.display_default_format <- function(format) {
73+
format <- getOption("easystats_display_format", "markdown")
74+
insight::validate_argument(format, c("markdown", "html", "md", "tt"))
75+
}

R/test_likelihoodratio.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ print_html.test_likelihoodratio <- function(x, digits = 2, ...) {
121121

122122
#' @export
123123
display.test_likelihoodratio <- function(object, format = "markdown", digits = 2, ...) {
124-
format <- insight::validate_argument(format, c("markdown", "md", "html", "tt"))
124+
format <- .display_default_format(format)
125125
if (format %in% c("html", "tt")) {
126126
print_html(
127127
x = object,

R/test_performance.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ print_html.test_performance <- function(x, digits = 2, ...) {
309309

310310
#' @export
311311
display.test_performance <- function(object, format = "markdown", digits = 2, ...) {
312-
format <- insight::validate_argument(format, c("markdown", "md", "html", "tt"))
312+
format <- .display_default_format(format)
313313
if (format %in% c("html", "tt")) {
314314
print_html(
315315
x = object,

man/display.performance_model.Rd

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)