Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 3.2.0
Date: 2026-06-23 16:43:46 UTC
SHA: 9892d5abc8c9278acd19835059bbe78ff887c7bc
Version: 3.4.0
Date: 2026-07-02 16:27:59 UTC
SHA: 16c8b4d791827785b68e78279b89c183b9d35d09
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: ggRandomForests
Type: Package
Title: Visually Exploring Random Forests
Version: 3.4.0
Date: 2026-07-01
Version: 3.4.1
Date: 2026-07-02
Authors@R: person("John", "Ehrlinger",
role = c("aut", "cre"),
email = "john.ehrlinger@gmail.com")
Expand Down
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ S3method(gg_beta_uvarpro,default)
S3method(gg_beta_uvarpro,uvarpro)
S3method(gg_beta_varpro,default)
S3method(gg_beta_varpro,varpro)
S3method(gg_brier,default)
S3method(gg_brier,rfsrc)
S3method(gg_error,default)
S3method(gg_error,randomForest)
S3method(gg_error,randomForest.formula)
S3method(gg_error,rfsrc)
S3method(gg_isopro,default)
S3method(gg_isopro,isopro)
S3method(gg_ivarpro,default)
S3method(gg_ivarpro,varpro)
S3method(gg_rfsrc,default)
S3method(gg_rfsrc,randomForest)
S3method(gg_rfsrc,rfsrc)
S3method(gg_roc,default)
Expand All @@ -41,8 +44,10 @@ S3method(gg_sdependent,default)
S3method(gg_sdependent,uvarpro)
S3method(gg_survival,default)
S3method(gg_survival,rfsrc)
S3method(gg_variable,default)
S3method(gg_variable,randomForest)
S3method(gg_variable,rfsrc)
S3method(gg_vimp,default)
S3method(gg_vimp,randomForest)
S3method(gg_vimp,rfsrc)
S3method(plot,gg_beta_uvarpro)
Expand Down
12 changes: 11 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
Package: ggRandomForests
Version: 3.4.0
Version: 3.4.1

ggRandomForests v3.4.1
======================
* The remaining `rfsrc`/`randomForest` wrappers -- `gg_error()`, `gg_vimp()`,
`gg_variable()`, `gg_rfsrc()`, and `gg_brier()` -- now have `default` S3
methods, so a wrong-class input gives a clear "expected an 'rfsrc' or
'randomForest' object" error (naming the class it got) instead of R's generic
"no applicable method". This finishes the dispatch-consistency pass started
for the varPro family in 3.4.0. (`gg_roc()` keeps its existing
`gg_roc.rfsrc` default, which accepts rfsrc-shaped objects.)

ggRandomForests v3.4.0
======================
Expand Down
7 changes: 7 additions & 0 deletions R/gg_brier.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ gg_brier <- function(object, ...) {
UseMethod("gg_brier", object)
}

#' @export
gg_brier.default <- function(object, ...) {
stop("gg_brier: expected an 'rfsrc' survival object from ",
"randomForestSRC::rfsrc(); got an object of class ",
paste(class(object), collapse = "/"), ".", call. = FALSE)
}

#' @export
gg_brier.rfsrc <- function(object,
subset = NULL,
Expand Down
7 changes: 7 additions & 0 deletions R/gg_error.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@
gg_error <- function(object, ...) {
UseMethod("gg_error", object)
}

#' @export
gg_error.default <- function(object, ...) {
stop("gg_error: expected an 'rfsrc' or 'randomForest' object; ",
"got an object of class ", paste(class(object), collapse = "/"), ".",
call. = FALSE)
}
#' @export
gg_error.rfsrc <- function(object, ...) {
## Check that the input object is of the correct type.
Expand Down
7 changes: 7 additions & 0 deletions R/gg_rfsrc.R
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,13 @@ gg_rfsrc <- function(object,
UseMethod("gg_rfsrc", object)
}

#' @export
gg_rfsrc.default <- function(object, oob = TRUE, by, ...) {
stop("gg_rfsrc: expected an 'rfsrc' or 'randomForest' object; ",
"got an object of class ", paste(class(object), collapse = "/"), ".",
call. = FALSE)
}

#' @export
gg_rfsrc.randomForest <- function(object,
oob = TRUE,
Expand Down
7 changes: 7 additions & 0 deletions R/gg_variable.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@
gg_variable <- function(object, ...) {
UseMethod("gg_variable", object)
}

#' @export
gg_variable.default <- function(object, ...) {
stop("gg_variable: expected an 'rfsrc' or 'randomForest' object; ",
"got an object of class ", paste(class(object), collapse = "/"), ".",
call. = FALSE)
}
#' @export
gg_variable.rfsrc <- function(object,
...) {
Expand Down
7 changes: 7 additions & 0 deletions R/gg_vimp.R
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@
gg_vimp <- function(object, nvar, ...) {
UseMethod("gg_vimp", object)
}

#' @export
gg_vimp.default <- function(object, nvar, ...) {
stop("gg_vimp: expected an 'rfsrc' or 'randomForest' object; ",
"got an object of class ", paste(class(object), collapse = "/"), ".",
call. = FALSE)
}
#' @export
gg_vimp.rfsrc <- function(object, nvar, ...) {
# Validate that the object is an rfsrc grow or predict result.
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test_default_dispatch.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Wrong-class inputs to the rfsrc/randomForest wrappers must error via their
# default S3 methods with a clear message. Fit-free, so these run on CRAN.

test_that("rfsrc/randomForest wrappers error on non-model input", {
bad <- data.frame(a = 1:3)

expect_error(gg_error(bad), "expected an 'rfsrc' or 'randomForest' object")
expect_error(gg_vimp(bad), "expected an 'rfsrc' or 'randomForest' object")
expect_error(gg_variable(bad), "expected an 'rfsrc' or 'randomForest' object")
expect_error(gg_rfsrc(bad), "expected an 'rfsrc' or 'randomForest' object")
expect_error(gg_brier(bad), "expected an 'rfsrc' survival object")

# The error names the class it actually got.
expect_error(gg_error(1:3), "got an object of class integer")
})
Loading