Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"noSuggests" R CMD check #79

Merged
merged 5 commits into from
Oct 15, 2024
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
59 changes: 59 additions & 0 deletions .github/workflows/R-CMD-check-hard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
#
# NOTE: This workflow only directly installs "hard" dependencies, i.e. Depends,
# Imports, and LinkingTo dependencies. Notably, Suggests dependencies are never
# installed, with the exception of testthat, knitr, and rmarkdown. The cache is
# never used to avoid accidentally restoring a cache containing a suggested
# dependency.
on:
push:
branches: [main, master]
pull_request:

name: R-CMD-check-hard.yaml

permissions: read-all

jobs:
check-no-suggests:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, r: 'release'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
dependencies: '"hard"'
cache: false
extra-packages: |
any::rcmdcheck
any::testthat
any::knitr
any::rmarkdown
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
61 changes: 31 additions & 30 deletions R/bagger.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,49 +44,50 @@
#' comparison of methods to study the contribution of variables in artificial
#' neural network models. Ecological Modelling, 160(3), 249-264.
#' @examples
#' library(recipes)
#' library(dplyr)
#' if (rlang::is_installed(c("recipes", "modeldata"))) {
#' library(recipes)
#' library(dplyr)
#'
#' data(biomass, package = "modeldata")
#' data(biomass, package = "modeldata")
#'
#' biomass_tr <-
#' biomass %>%
#' dplyr::filter(dataset == "Training") %>%
#' dplyr::select(-dataset, -sample)
#' biomass_tr <-
#' biomass %>%
#' dplyr::filter(dataset == "Training") %>%
#' dplyr::select(-dataset, -sample)
#'
#' biomass_te <-
#' biomass %>%
#' dplyr::filter(dataset == "Testing") %>%
#' dplyr::select(-dataset, -sample)
#' biomass_te <-
#' biomass %>%
#' dplyr::filter(dataset == "Testing") %>%
#' dplyr::select(-dataset, -sample)
#'
#' # ------------------------------------------------------------------------------
#' # ------------------------------------------------------------------------------
#'
#' ctrl <- control_bag(var_imp = TRUE)
#' ctrl <- control_bag(var_imp = TRUE)
#'
#' # ------------------------------------------------------------------------------
#' # ------------------------------------------------------------------------------
#'
#' # `times` is low to make the examples run faster
#' # `times` is low to make the examples run faster
#'
#'
#' set.seed(7687)
#' cart_bag <- bagger(x = biomass_tr[, -6], y = biomass_tr$HHV,
#' base_model = "CART", times = 5, control = ctrl)
#' cart_bag
#'
#' # ------------------------------------------------------------------------------
#' # Other interfaces
#' set.seed(7687)
#' cart_bag <- bagger(x = biomass_tr[, -6], y = biomass_tr$HHV,
#' base_model = "CART", times = 5, control = ctrl)
#' cart_bag
#'
#' # Recipes can be used
#' biomass_rec <-
#' recipe(HHV ~ ., data = biomass_tr) %>%
#' step_pca(all_predictors())
#' # ------------------------------------------------------------------------------
#' # Other interfaces
#'
#' set.seed(7687)
#' cart_pca_bag <- bagger(biomass_rec, data = biomass_tr, base_model = "CART",
#' times = 5, control = ctrl)
#' # Recipes can be used
#' biomass_rec <-
#' recipe(HHV ~ ., data = biomass_tr) %>%
#' step_pca(all_predictors())
#'
#' cart_pca_bag
#' set.seed(7687)
#' cart_pca_bag <- bagger(biomass_rec, data = biomass_tr, base_model = "CART",
#' times = 5, control = ctrl)
#'
#' cart_pca_bag
#' }
#' @export
bagger <- function(x, ...) {
UseMethod("bagger")
Expand Down
61 changes: 31 additions & 30 deletions man/bagger.Rd

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

13 changes: 9 additions & 4 deletions tests/testthat/helper-baguette.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
library(rlang)
library(purrr)
library(yardstick)
library(recipes)

data("two_class_dat", package = "modeldata")
if (is_installed("yardstick")) {
library(yardstick)
}
if (is_installed("recipes")) {
library(recipes)
}
if (is_installed("modeldata")) {
data("two_class_dat", package = "modeldata")
}

# ------------------------------------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-C5.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ test_that('check model reduction', {
# ------------------------------------------------------------------------------

test_that('check C5 parsnip interface', {
skip_if_not_installed("modeldata")

set.seed(4779)
expect_error(
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-cart.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test_that('check CART opt', {
skip_if_not_installed("modeldata")

mod_1 <-
bagger(
Expand Down Expand Up @@ -99,6 +100,8 @@ test_that('check model reduction', {
# ------------------------------------------------------------------------------

test_that('check CART parsnip interface', {
skip_if_not_installed("modeldata")

set.seed(4779)
expect_error(
reg_mod <- bag_tree(cost_complexity = .001, min_n = 3) %>%
Expand Down Expand Up @@ -204,6 +207,7 @@ test_that('mode specific package dependencies', {

test_that('case weights', {
skip_if_not_installed("modeldata")

data("two_class_dat", package = "modeldata")
set.seed(1)
wts <- runif(nrow(two_class_dat))
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-interfaces.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
test_that('recipe execution', {
skip_if_not_installed("recipes")

# check to make sure that prepped data are given to model
rec <-
recipe(Sepal.Length ~ ., data = iris) %>%
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-mars.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
test_that('check mars opt', {
skip_if_not_installed("earth")
skip_if_not_installed("modeldata")

set.seed(36323)
check_pruning <- function(x, ...) {
rlang::eval_tidy(x$call$pmethod) == "backward"
Expand Down Expand Up @@ -91,6 +93,8 @@ test_that('check model reduction', {

test_that('check MARS parsnip interface', {
skip_if_not_installed("earth")
skip_if_not_installed("modeldata")

set.seed(4779)
expect_error(
reg_mod <- bag_mars(num_terms = 5, prod_degree = 2) %>%
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-nnet.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

test_that('check nnet parsnip interface', {
skip_if_not_installed("nnet")
skip_if_not_installed("modeldata")

data(two_class_dat, package = "modeldata")

set.seed(4779)
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-validation.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ test_that('validate imps', {

test_that('bad inputs', {
skip_if_not_installed("earth")
skip_if_not_installed("modeldata")

expect_error(
bagger(mpg ~ ., data = mtcars, base_model = letters[1:2]),
"should be a single character value."
Expand Down
Loading