Skip to content

Commit

Permalink
desc, news
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Mar 14, 2024
1 parent c7063eb commit 0b8fcfc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
of class `clmm` (package *ordinal*), when model had no `component` column
(e.g., no scale or location parameters were returned).

* `include_reference` now also works when factor were created "on-the-fly" inside
the model formula (i.e. `y ~ as.factor(x)`).

# parameters 0.21.5

## Bug fixes
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@
# extract all model terms, we now have "as.factor(term)" etc., if any
if (!is.null(model_terms$conditional)) {
# extract variable names from "as.factor(term)" etc.
factor_terms <- grep("(as\\.factor|factor)", model_terms$conditional, value = TRUE)
cleaned <- gsub("(as\\.factor|factor)\\((.*)\\)", "\\2", factor_terms)
factor_terms <- grep("(as\\.factor|factor|as\\.character)", model_terms$conditional, value = TRUE)
cleaned <- gsub("(as\\.factor|factor|as\\.character)\\((.*)\\)", "\\2", factor_terms)
# convert on-the-fly factors into real factors
if (length(cleaned)) {
for (i in seq_along(cleaned)) {
Expand Down
4 changes: 2 additions & 2 deletions R/utils_format.R
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@

# for on-the-fly conversion of factors, the names of the factors can
# can also contain "factor()" or "as.factor()" - we need to remove these
if (any(grepl("(as\\.factor|factor)", fn))) {
fn_clean <- gsub("(as\\.factor|factor)\\((.*)\\)", "\\2", fn)
if (any(grepl("(as\\.factor|factor|as\\.character)", fn))) {
fn_clean <- gsub("(as\\.factor|factor|as\\.character)\\((.*)\\)", "\\2", fn)

Check warning on line 426 in R/utils_format.R

View check run for this annotation

Codecov / codecov/patch

R/utils_format.R#L426

Added line #L426 was not covered by tests
} else {
fn_clean <- fn
}
Expand Down

0 comments on commit 0b8fcfc

Please sign in to comment.