Skip to content

Commit

Permalink
CRAN submission 0.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Sep 13, 2023
1 parent 1bb0cd6 commit d3a6a95
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: parameters
Title: Processing of Model Parameters
Version: 0.21.1.9
Version: 0.21.1.10
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down Expand Up @@ -81,7 +81,7 @@ Depends:
Imports:
bayestestR (>= 0.13.0),
datawizard (>= 0.7.0),
insight (>= 0.19.3.2),
insight (>= 0.19.4),
graphics,
methods,
stats,
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
accepts the `exponentiate` argument.

* The `print()`, `print_html()`, `print_md()` and `format()` methods for
`model_parameters()` get an `add_reference` argument, to add the reference
`model_parameters()` get an `include_reference` argument, to add the reference
category of categorical predictors to the parameters table.

## Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion R/display.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ display.parameters_model <- function(object,
font_size = "100%",
line_padding = 4,
column_labels = NULL,
add_reference = FALSE,
include_reference = FALSE,
verbose = TRUE,
...) {
if (identical(format, "html")) {
Expand Down
6 changes: 3 additions & 3 deletions R/format.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ format.parameters_model <- function(x,
zap_small = FALSE,
format = NULL,
groups = NULL,
add_reference = FALSE,
include_reference = FALSE,
...) {
# save attributes
coef_name <- attributes(x)$coefficient_name
Expand Down Expand Up @@ -168,7 +168,7 @@ format.parameters_model <- function(x,
ci_width = ci_width,
ci_brackets = ci_brackets,
zap_small = zap_small,
add_reference = add_reference,
include_reference = include_reference,
...
)
} else {
Expand All @@ -185,7 +185,7 @@ format.parameters_model <- function(x,
format = format,
coef_name = coef_name,
zap_small = zap_small,
add_reference = add_reference,
include_reference = include_reference,
...
)
}
Expand Down
10 changes: 5 additions & 5 deletions R/print.parameters_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
#' labels will be used as parameters names. The latter only works for "labelled"
#' data, i.e. if the data used to fit the model had `"label"` and `"labels"`
#' attributes. See also section _Global Options to Customize Messages when Printing_.
#' @param add_reference Logical, if `TRUE`, the reference level of factors will
#' @param include_reference Logical, if `TRUE`, the reference level of factors will
#' be added to the parameters table. This is only relevant for models with
#' categorical predictors. The coefficient for the reference level is always
#' `0` (except when `exponentiate = TRUE`, then the coefficient will be `1`),
Expand Down Expand Up @@ -238,7 +238,7 @@ print.parameters_model <- function(x,
groups = NULL,
column_width = NULL,
ci_brackets = c("[", "]"),
add_reference = FALSE,
include_reference = FALSE,
...) {
# save original input
orig_x <- x
Expand Down Expand Up @@ -288,7 +288,7 @@ print.parameters_model <- function(x,
ci_brackets = ci_brackets,
format = "text",
groups = groups,
add_reference = add_reference,
include_reference = include_reference,
...
)

Expand Down Expand Up @@ -385,7 +385,7 @@ print.parameters_random <- function(x, digits = 2, ...) {
ci_brackets = TRUE,
format = "text",
group = NULL,
add_reference = FALSE,
include_reference = FALSE,
...) {
format(
x,
Expand All @@ -400,7 +400,7 @@ print.parameters_random <- function(x, digits = 2, ...) {
zap_small = zap_small,
format = format,
group = group,
add_reference = add_reference,
include_reference = include_reference,
...
)
}
Expand Down
4 changes: 2 additions & 2 deletions R/print_html.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ print_html.parameters_model <- function(x,
font_size = "100%",
line_padding = 4,
column_labels = NULL,
add_reference = FALSE,
include_reference = FALSE,
verbose = TRUE,
...) {
# check if user supplied digits attributes
Expand Down Expand Up @@ -83,7 +83,7 @@ print_html.parameters_model <- function(x,
ci_brackets = ci_brackets,
format = "html",
groups = groups,
add_reference = add_reference,
include_reference = include_reference,
...
)

Expand Down
4 changes: 2 additions & 2 deletions R/print_md.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ print_md.parameters_model <- function(x,
show_formula = FALSE,
zap_small = FALSE,
groups = NULL,
add_reference = FALSE,
include_reference = FALSE,
verbose = TRUE,
...) {
# check if user supplied digits attributes
Expand Down Expand Up @@ -67,7 +67,7 @@ print_md.parameters_model <- function(x,
ci_brackets = ci_brackets,
format = "markdown",
groups = groups,
add_reference = add_reference,
include_reference = include_reference,
...
)

Expand Down
8 changes: 4 additions & 4 deletions R/utils_format.R
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@
format = NULL,
coef_name = NULL,
zap_small = FALSE,
add_reference = FALSE,
include_reference = FALSE,
...) {
# default brackets are parenthesis for HTML / MD
if ((is.null(ci_brackets) || isTRUE(ci_brackets)) && (identical(format, "html") || identical(format, "markdown"))) {
Expand Down Expand Up @@ -310,7 +310,7 @@
}

# add the coefficient for the base-(reference)-level of factors?
if (add_reference) {
if (include_reference) {
x <- .add_reference_level(x)
}

Expand Down Expand Up @@ -851,7 +851,7 @@
ci_width = "auto",
ci_brackets = TRUE,
zap_small = FALSE,
add_reference = FALSE,
include_reference = FALSE,
...) {
final_table <- list()

Expand Down Expand Up @@ -1052,7 +1052,7 @@
}

# add the coefficient for the base-(reference)-level of factors?
if (add_reference) {
if (include_reference) {
tables[[type]] <- .add_reference_level(tables[[type]])
}

Expand Down
10 changes: 5 additions & 5 deletions man/display.parameters_model.Rd

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

4 changes: 2 additions & 2 deletions man/print.parameters_model.Rd

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

10 changes: 5 additions & 5 deletions tests/testthat/test-printing_reference_level.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@
# d <<- PlantGrowth
# m <- lm(weight ~ group, data = d)
# mp <- model_parameters(m)
# expect_snapshot(print(mp, add_reference = TRUE))
# expect_snapshot(print(mp, include_reference = TRUE))

# data(mtcars)
# d <<- mtcars
# d$cyl <- as.factor(d$cyl)
# d$am <- as.factor(d$am)
# m <- lm(mpg ~ hp + cyl + gear + am, data = d)
# mp <- model_parameters(m)
# expect_snapshot(print(mp, add_reference = TRUE))
# expect_snapshot(print(mp, include_reference = TRUE))

# data(iris)
# d <<- iris
# m <- lm(Sepal.Length ~ Sepal.Width * Species, data = d)
# mp <- model_parameters(m)
# expect_snapshot(print(mp, add_reference = TRUE))
# expect_snapshot(print(mp, include_reference = TRUE))

# data(mtcars)
# d <<- mtcars
# d$gear <- as.factor(d$gear)
# m <- glm(vs ~ wt + gear, data = d, family = "binomial")
# expect_snapshot(print(model_parameters(m, exponentiate = TRUE, drop = "(Intercept)"), add_reference = TRUE))
# expect_snapshot(print(model_parameters(m, exponentiate = TRUE, drop = "(Intercept)"), include_reference = TRUE))
# })

# test_that("reference for models with multiple components", {
Expand All @@ -40,5 +40,5 @@
# family = glmmTMB::truncated_poisson()
# )

# print(model_parameters(m1), add_reference = TRUE)
# print(model_parameters(m1), include_reference = TRUE)
# })

0 comments on commit d3a6a95

Please sign in to comment.