Skip to content

Commit d0f0cfe

Browse files
topepo‘topepo’
and
‘topepo’
authored
Changes for #71 (#72)
Co-authored-by: ‘topepo’ <‘[email protected]’>
1 parent 6c23e76 commit d0f0cfe

13 files changed

+20
-28
lines changed

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Imports:
2222
C50,
2323
dials,
2424
dplyr,
25-
earth,
2625
furrr,
2726
generics,
2827
hardhat (>= 1.1.0),
@@ -38,6 +37,7 @@ Imports:
3837
Suggests:
3938
AmesHousing,
4039
covr,
40+
earth,
4141
modeldata,
4242
nnet,
4343
recipes,
@@ -50,4 +50,4 @@ Config/testthat/edition: 3
5050
Encoding: UTF-8
5151
Language: en-US
5252
Roxygen: list(markdown = TRUE)
53-
RoxygenNote: 7.2.3
53+
RoxygenNote: 7.3.1

NAMESPACE

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ importFrom(C50,C5.0Control)
2323
importFrom(C50,C5imp)
2424
importFrom(C50,as.party.C5.0)
2525
importFrom(dials,new_quant_param)
26-
importFrom(earth,earth)
27-
importFrom(earth,evimp)
2826
importFrom(furrr,future_map)
2927
importFrom(furrr,future_map2)
3028
importFrom(generics,var_imp)

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# baguette (development version)
22

3+
* Move the earth package to Suggests due to CRAN note about the TeachingDemos (#71).
4+
35
# baguette 1.0.1
46

57
* Added a `"nnet"` method for `bagger()`.

R/aaa.R

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#' @importFrom parsnip new_model_spec null_value update_main_parameters
88
#' @importFrom parsnip check_final_param model_printer show_call
99
#' @importFrom utils globalVariables
10-
#' @importFrom earth earth evimp
1110
#' @importFrom rsample analysis bootstraps assessment
1211
#' @importFrom purrr map map2 map_df map_dfr map_lgl
1312
#' @importFrom tibble tibble as_tibble is_tibble

R/bagger.R

-9
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@
6767
#'
6868
#' # `times` is low to make the examples run faster
6969
#'
70-
#' set.seed(7687)
71-
#' mars_bag <- bagger(x = biomass_tr[, -6], y = biomass_tr$HHV,
72-
#' base_model = "MARS", times = 5, control = ctrl)
73-
#' mars_bag
74-
#' var_imp(mars_bag)
7570
#'
7671
#' set.seed(7687)
7772
#' cart_bag <- bagger(x = biomass_tr[, -6], y = biomass_tr$HHV,
@@ -92,10 +87,6 @@
9287
#'
9388
#' cart_pca_bag
9489
#'
95-
#' # Using formulas
96-
#' mars_bag <- bagger(HHV ~ ., data = biomass_tr, base_model = "MARS", times = 5,
97-
#' control = ctrl)
98-
#' mars_bag
9990
#' @export
10091
bagger <- function(x, ...) {
10192
UseMethod("bagger")

R/mars.R

+4-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ mars_fit <- function(split, spec, control = control_bag()) {
100100
}
101101

102102
mars_imp <- function(x) {
103-
imps <- earth::evimp(x$fit)
103+
# see issue 71
104+
rlang::check_installed("earth")
105+
cl <- rlang::call2("evimp", .ns = "earth", object = quote(x$fit))
106+
imps <- rlang::eval_tidy(cl)
104107
imps <- imps[, "gcv", drop = FALSE]
105108
x <- tibble::tibble(predictor = rownames(imps), importance = unname(imps[, "gcv"]))
106109
x <- x[x$importance > 0,]

R/predict.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#' data(airquality)
1616
#'
1717
#' set.seed(7687)
18-
#' mars_bag <- bagger(Ozone ~ ., data = airquality, base_model = "MARS", times = 5)
19-
#' predict(mars_bag, new_data = airquality[, -1])
18+
#' cart_bag <- bagger(Ozone ~ ., data = airquality, base_model = "CART", times = 5)
19+
#' predict(cart_bag, new_data = airquality[, -1])
2020
#' @export
2121
predict.bagger <- function(object, new_data, type = NULL, ...) {
2222
type <- check_type(object, type)

inst/WORDLIST

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Lifecycle
88
Modelling
99
ORCID
1010
PBC
11+
TeachingDemos
1112
al
1213
doi
1314
et

man/bagger.Rd

-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/predict.bagger.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-interfaces.R

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ test_that('recipe execution', {
2828
# ------------------------------------------------------------------------------
2929

3030
test_that('var_imp', {
31+
skip_if_not_installed("earth")
3132
mod <- bagger(mpg ~ ., data = mtcars, base_model = "MARS", times = 2)
3233
expect_true(tibble::is_tibble(var_imp(mod)))
3334
expect_equal(names(var_imp(mod)), c("term", "value", "std.error", "used"))

tests/testthat/test-mars.R

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
test_that('check mars opt', {
2+
skip_if_not_installed("earth")
23
set.seed(36323)
34
check_pruning <- function(x, ...) {
45
rlang::eval_tidy(x$call$pmethod) == "backward"
@@ -57,6 +58,7 @@ test_that('check mars opt', {
5758
# ------------------------------------------------------------------------------
5859

5960
test_that('check model reduction', {
61+
skip_if_not_installed("earth")
6062
set.seed(36323)
6163
reduced <-
6264
bagger(
@@ -88,6 +90,7 @@ test_that('check model reduction', {
8890
# ------------------------------------------------------------------------------
8991

9092
test_that('check MARS parsnip interface', {
93+
skip_if_not_installed("earth")
9194
set.seed(4779)
9295
expect_error(
9396
reg_mod <- bag_mars(num_terms = 5, prod_degree = 2) %>%
@@ -149,6 +152,7 @@ test_that('check MARS parsnip interface', {
149152
})
150153

151154
test_that('mode specific package dependencies', {
155+
skip_if_not_installed("earth")
152156
expect_identical(
153157
get_from_env(paste0("bag_mars", "_pkgs")) %>%
154158
dplyr::filter(engine == "earth", mode == "classification") %>%
@@ -167,6 +171,7 @@ test_that('mode specific package dependencies', {
167171

168172

169173
test_that('case weights', {
174+
skip_if_not_installed("earth")
170175
set.seed(1)
171176
wts <- runif(nrow(mtcars))
172177

tests/testthat/test-validation.R

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ test_that('validate imps', {
8787
# ------------------------------------------------------------------------------
8888

8989
test_that('bad inputs', {
90+
skip_if_not_installed("earth")
9091
expect_error(
9192
bagger(mpg ~ ., data = mtcars, base_model = letters[1:2]),
9293
"should be a single character value."

0 commit comments

Comments
 (0)