Skip to content

Commit

Permalink
Use internal copy of to_numeric() (#191)
Browse files Browse the repository at this point in the history
* Use internal copy of to_numeric

Since it will be removed from datawizard: easystats/datawizard#197 (comment)

modelbased needs to be updated on CRAN before datawizard.

* Update render-readme.yml

* Update render-readme.yml
  • Loading branch information
IndrajeetPatil authored Jul 22, 2022
1 parent 671ba59 commit 005e2ba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/render-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ name: render-readme

jobs:
render-readme:
runs-on: ubuntu-latest
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion R/estimate_grouplevel.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ estimate_grouplevel <- function(model, type = "random", ...) {
random <- random[c("Group", "Level", names(random)[!names(random) %in% c("Group", "Level")])]

# Sort
random <- random[order(random$Group, datawizard::to_numeric(random$Level), random$Parameter), ]
random <- random[order(random$Group, .to_numeric(random$Level), random$Parameter), ]

# Clean
row.names(random) <- NULL
Expand Down
8 changes: 8 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#' @keywords internal
#' @noRd
.to_numeric <- function(x) {
tryCatch(as.numeric(as.character(x)),
error = function(e) x,
warning = function(w) x
)
}
2 changes: 1 addition & 1 deletion R/visualisation_recipe.estimate_grouplevel.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ visualisation_recipe.estimate_grouplevel <- function(x,
...) {
data <- as.data.frame(x)
# Fix order so that it's plotted with sorted levels
data$Level <- factor(data$Level, levels = sort(datawizard::to_numeric(unique(data$Level))))
data$Level <- factor(data$Level, levels = sort(.to_numeric(unique(data$Level))))

layers <- list()

Expand Down

0 comments on commit 005e2ba

Please sign in to comment.