Skip to content

Commit 3aa80c7

Browse files
authored
digits display option doesn't get passed to AIC/BIC (#863)
1 parent bcfc470 commit 3aa80c7

File tree

6 files changed

+53
-37
lines changed

6 files changed

+53
-37
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.2
4+
Version: 0.15.2.1
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# performance (devel)
2+
3+
## Changes
4+
5+
* Improved documentation for printing-methods.
6+
17
# performance 0.15.2
28

39
## Bug fixes

R/display.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
#' @param layout Table layout (can be either `"horizontal"` or `"vertical"`).
1414
#' @param digits Number of decimal places.
1515
#' @param caption Table caption as string. If `NULL`, no table caption is printed.
16-
#' @param ... Currently not used.
16+
#' @param ... Arguments passed to other methods, e.g. `format()` (and thereby to
17+
#' [`insight::format_table()`] or [`insight::export_table()`]. See related
18+
#' documentation for details on available arguments. For example, to control
19+
#' digits for information criteria like AIC or BIC, use `ic_digits = <value>`.
1720
#'
1821
#' @section Global Options to Customize Output when Printing:
1922
#'
@@ -35,6 +38,7 @@
3538
#' model <- lm(mpg ~ wt + cyl, data = mtcars)
3639
#' mp <- model_performance(model)
3740
#' display(mp)
41+
#' display(mp, digits = 3, ic_digits = 4)
3842
#' @export
3943
display.performance_model <- function(
4044
object,

R/model_performance.R

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,36 +39,3 @@ model_performance <- function(model, ...) {
3939
#' @rdname model_performance
4040
#' @export
4141
performance <- model_performance
42-
43-
44-
# methods --------------------------------
45-
46-
#' @export
47-
print.performance_model <- function(x, digits = 3, layout = "horizontal", ...) {
48-
layout <- insight::validate_argument(
49-
layout,
50-
c("horizontal", "vertical")
51-
)
52-
formatted_table <- format(x = x, digits = digits, format = "text", ...)
53-
54-
# switch to vertical layout
55-
if (layout == "vertical") {
56-
formatted_table <- datawizard::rownames_as_column(
57-
as.data.frame(t(formatted_table)),
58-
"Metric"
59-
)
60-
colnames(formatted_table)[2] <- "Value"
61-
}
62-
63-
cat(
64-
insight::export_table(
65-
x = formatted_table,
66-
digits = digits,
67-
format = "text",
68-
caption = c("# Indices of model performance", "blue"),
69-
...
70-
)
71-
)
72-
73-
invisible(x)
74-
}

R/print-methods.R

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
#' @rdname display.performance_model
2+
#' @export
3+
print.performance_model <- function(x, digits = 3, layout = "horizontal", ...) {
4+
layout <- insight::validate_argument(
5+
layout,
6+
c("horizontal", "vertical")
7+
)
8+
formatted_table <- format(x = x, digits = digits, format = "text", ...)
9+
10+
# switch to vertical layout
11+
if (layout == "vertical") {
12+
formatted_table <- datawizard::rownames_as_column(
13+
as.data.frame(t(formatted_table)),
14+
"Metric"
15+
)
16+
colnames(formatted_table)[2] <- "Value"
17+
}
18+
19+
cat(
20+
insight::export_table(
21+
x = formatted_table,
22+
digits = digits,
23+
format = "text",
24+
caption = c("# Indices of model performance", "blue"),
25+
...
26+
)
27+
)
28+
29+
invisible(x)
30+
}
31+
32+
133
#' @export
234
print.r2_generic <- function(x, digits = 3, ...) {
335
model_type <- attr(x, "model_type")

man/display.performance_model.Rd

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

0 commit comments

Comments
 (0)