Skip to content

Commit

Permalink
changes for CRAN check; see Rdatatable/data.table#5658
Browse files Browse the repository at this point in the history
  • Loading branch information
topepo committed Aug 16, 2023
1 parent 0c43d67 commit 2c5e1c8
Show file tree
Hide file tree
Showing 92 changed files with 173 additions and 65 deletions.
4 changes: 2 additions & 2 deletions R/aaa_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ model_info_table <-
#' @keywords internal
#' @references "How to build a parsnip model"
#' \url{https://www.tidymodels.org/learn/develop/models/}
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' # Access the model data:
#' current_code <- get_model_env()
#' ls(envir = current_code)
Expand Down Expand Up @@ -552,7 +552,7 @@ check_interface_val <- function(x) {
#'
#' @references "How to build a parsnip model"
#' \url{https://www.tidymodels.org/learn/develop/models/}
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' # set_new_model("shallow_learning_model")
#'
#' # Show the information about a model:
Expand Down
2 changes: 1 addition & 1 deletion R/aaa_multi_predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ predict.model_spec <- function(object, ...) {
#' `multi_predict_args()` returns a character vector of argument names (or `NA`
#' if none exist).
#' @keywords internal
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' lm_model_idea <- linear_reg() %>% set_engine("lm")
#' has_multi_predict(lm_model_idea)
#' lm_model_fit <- fit(lm_model_idea, mpg ~ ., data = mtcars)
Expand Down
2 changes: 1 addition & 1 deletion R/adds.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @param x A data frame
#' @return The same data frame with a column of 1-based integers named `.row`.
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' mtcars %>% add_rowindex()
#' @export
add_rowindex <- function(x) {
Expand Down
4 changes: 2 additions & 2 deletions R/arguments.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ check_eng_args <- function(args, obj, core_args) {
#' @return An updated model object.
#' @details `set_args()` will replace existing values of the arguments.
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' rand_forest()
#'
#' rand_forest() %>%
Expand Down Expand Up @@ -294,7 +294,7 @@ make_xy_call <- function(object, target, env) {
#' @param offset A number subtracted off of the number of rows available in the
#' data.
#' @return An integer (and perhaps a warning).
#' @examples
#' @examplesIf !parsnip:::is_cran_check()

#' nearest_neighbor(neighbors= 100) %>%
#' set_engine("kknn") %>%
Expand Down
2 changes: 1 addition & 1 deletion R/augment.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#' @references
#' \url{https://www.tidymodels.org/learn/statistics/survival-metrics/}
#' @export
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' car_trn <- mtcars[11:32,]
#' car_tst <- mtcars[ 1:10,]
#'
Expand Down
2 changes: 1 addition & 1 deletion R/bart.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#'
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("bart")}
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' show_engines("bart")
#'
#' bart(mode = "regression", trees = 5)
Expand Down
2 changes: 1 addition & 1 deletion R/boost_tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("boost_tree")},
#' [xgb_train()], [C5.0_train()]
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' show_engines("boost_tree")
#'
#' boost_tree(mode = "classification", trees = 20)
Expand Down
4 changes: 2 additions & 2 deletions R/c5_rules.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#' @seealso [C50::C5.0()], [C50::C5.0Control()],
#' \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("C5_rules")}
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' show_engines("C5_rules")
#'
#' C5_rules()
Expand Down Expand Up @@ -73,7 +73,7 @@ C5_rules <-
#'
#' @param object A `C5_rules` model specification.
#' @inheritParams update.boost_tree
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#'
#' # ------------------------------------------------------------------------------
#'
Expand Down
2 changes: 1 addition & 1 deletion R/condense_control.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' @keywords internal
#' @export
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' ctrl <- control_parsnip(catch = TRUE)
#' ctrl$allow_par <- TRUE
#' str(ctrl)
Expand Down
2 changes: 1 addition & 1 deletion R/control_parsnip.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' @return An S3 object with class "control_parsnip" that is a named list
#' with the results of the function call
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' control_parsnip(verbosity = 2L)
#'
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/cubist_rules.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ cubist_rules <-
# ------------------------------------------------------------------------------

#' @param object A Cubist model specification.
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#'
#' # ------------------------------------------------------------------------------
#'
Expand Down
2 changes: 1 addition & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @docType data
#' @return \item{model_db}{a data frame}
#' @keywords datasets internal
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' data(model_db)
NULL

2 changes: 1 addition & 1 deletion R/decision_tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#'
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("decision_tree")}
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' show_engines("decision_tree")
#'
#' decision_tree(mode = "classification", tree_depth = 5)
Expand Down
2 changes: 1 addition & 1 deletion R/engine_docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ update_model_info_file <- function(path = "inst/models.tsv") {
#' @name doc-tools
#' @keywords internal
#' @export
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' # See this file for step-by-step instructions.
#' system.file("README-DOCS.md", package = "parsnip")
#'
Expand Down
4 changes: 2 additions & 2 deletions R/engines.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ load_libs <- function(x, quiet, attach = FALSE) {
#' @param ... Any optional arguments associated with the chosen computational
#' engine. These are captured as quosures and can be tuned with `tune()`.
#' @return An updated model specification.
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' # First, set main arguments using the standardized names
#' logistic_reg(penalty = 0.01, mixture = 1/3) %>%
#' # Now specify how you want to fit the model with another argument
Expand Down Expand Up @@ -160,7 +160,7 @@ set_engine.default <- function(object, engine, ...) {
#' @param x The name of a `parsnip` model (e.g., "linear_reg", "mars", etc.)
#' @return A tibble.
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' show_engines("linear_reg")
#' @export
show_engines <- function(x) {
Expand Down
2 changes: 1 addition & 1 deletion R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#' section.
#'
#' @name extract-parsnip
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' lm_spec <- linear_reg() %>% set_engine("lm")
#' lm_fit <- fit(lm_spec, mpg ~ ., data = mtcars)
#'
Expand Down
2 changes: 1 addition & 1 deletion R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#' a "reverse Kaplan-Meier" curve that models the probability of censoring. This
#' may be used later to compute inverse probability censoring weights for
#' performance measures.
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' # Although `glm()` only has a formula interface, different
#' # methods for specifying the model can be used
#'
Expand Down
2 changes: 1 addition & 1 deletion R/fit_control.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' @return An S3 object with class "control_parsnip" that is a named list
#' with the results of the function call
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' fit_control(verbosity = 2L)
#'
#' @details
Expand Down
2 changes: 1 addition & 1 deletion R/gen_additive_mod.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#'
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("gen_additive_mod")}
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' show_engines("gen_additive_mod")
#'
#' gen_additive_mod()
Expand Down
2 changes: 1 addition & 1 deletion R/grouped_binomial.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' @param ... Options to pass to [stats::glm()]. If `family` is not set, it will
#' automatically be assigned the basic binomial family.
#' @return A object produced by [stats::glm()].
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' #----------------------------------------------------------------------------
#' # The same data set formatted three ways
#'
Expand Down
2 changes: 1 addition & 1 deletion R/linear_reg.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#'
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("linear_reg")}
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' show_engines("linear_reg")
#'
#' linear_reg()
Expand Down
2 changes: 1 addition & 1 deletion R/logistic_reg.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#'
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("logistic_reg")}
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' show_engines("logistic_reg")
#'
#' logistic_reg()
Expand Down
2 changes: 1 addition & 1 deletion R/mars.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#'
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("mars")}
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' show_engines("mars")
#'
#' mars(mode = "regression", num_terms = 5)
Expand Down
17 changes: 17 additions & 0 deletions R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -526,3 +526,20 @@ check_for_newdata <- function(..., call = rlang::caller_env()) {
)
}
}


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

# driven by https://github.com/Rdatatable/data.table/issues/5658
# nocov start
# adapted from ps:::is_cran_check()
is_cran_check <- function() {
if (identical(Sys.getenv("NOT_CRAN"), "true")) {
FALSE
}
else {
Sys.getenv("_R_CHECK_PACKAGE_NAME_", "") != ""
}
}
# nocov end

2 changes: 1 addition & 1 deletion R/mlp.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#'
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("mlp")}
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' show_engines("mlp")
#'
#' mlp(mode = "classification", penalty = 0.01)
Expand Down
2 changes: 1 addition & 1 deletion R/model_object_docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ NULL
#' stores model objects after seeing the data and applying a model.
#' @rdname model_fit
#' @name model_fit
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#'
#' # Keep the `x` matrix if the data are not too big.
#' spec_obj <-
Expand Down
2 changes: 1 addition & 1 deletion R/multinom_reg.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#'
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("multinom_reg")}
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' show_engines("multinom_reg")
#'
#' multinom_reg()
Expand Down
2 changes: 1 addition & 1 deletion R/nearest_neighbor.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#'
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("nearest_neighbor")}
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' show_engines("nearest_neighbor")
#'
#' nearest_neighbor(neighbors = 11)
Expand Down
6 changes: 3 additions & 3 deletions R/nullmodel.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#' `predict.nullmodel()` returns either a factor or numeric vector
#' depending on the class of \code{y}. All predictions are always the same.
#' @keywords models internal
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#'
#' outcome <- factor(sample(letters[1:2],
#' size = 100,
Expand Down Expand Up @@ -140,7 +140,7 @@ predict.nullmodel <- function (object, new_data = NULL, type = NULL, ...) {
#' @includeRmd man/rmd/null-model.md details
#'
#' @seealso [fit.model_spec()]
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' null_model(mode = "regression")
#' @export
null_model <-
Expand Down Expand Up @@ -178,7 +178,7 @@ null_model <-
#' @return A tibble with column `value`.
#' @export
#' @keywords internal
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#'
#' nullmodel(mtcars[,-1], mtcars$mpg) %>% tidy()

Expand Down
4 changes: 2 additions & 2 deletions R/partykit.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' @param ntree Number of trees to grow in a forest.
#' @param ... Other options to pass to [partykit::ctree()] or [partykit::cforest()].
#' @return An object of class `party` (for `ctree`) or `cforest`.
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' if (rlang::is_installed(c("modeldata", "partykit"))) {
#' data(bivariate, package = "modeldata")
#' ctree_train(Class ~ ., data = bivariate_train)
Expand Down Expand Up @@ -184,7 +184,7 @@ cforest_train <-
#' @param formula A model formula.
#' @param data The training set (data frame).
#' @return A value for `mtry`.
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' # should be 9
#' max_mtry_formula(200, cbind(wt, mpg) ~ ., data = mtcars)
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/pls.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pls <-
#' @param ... Not used for `update()`.
#' @param fresh A logical for whether the arguments should be
#' modified in-place of or replaced wholesale.
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' model <- pls(predictor_prop = 0.1)
#' model
#' update(model, predictor_prop = 1)
Expand Down
2 changes: 1 addition & 1 deletion R/predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
#' multivariate models.
#' @references
#' \url{https://www.tidymodels.org/learn/statistics/survival-metrics/}
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' library(dplyr)
#'
#' lm_model <-
Expand Down
2 changes: 1 addition & 1 deletion R/proportional_hazards.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#'
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("proportional_hazards")}
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' show_engines("proportional_hazards")
#'
#' proportional_hazards(mode = "censored regression")
Expand Down
2 changes: 1 addition & 1 deletion R/rand_forest.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#'
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("rand_forest")}
#'
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' show_engines("rand_forest")
#'
#' rand_forest(mode = "classification", trees = 2000)
Expand Down
2 changes: 1 addition & 1 deletion R/repair_call.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' is the data frame that was given to `parsnip` for the model fit (i.e., the
#' training set data). The name of this data object is inserted into the call.
#' @return A modified `parsnip` fitted model.
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#'
#' fitted_model <-
#' linear_reg() %>%
Expand Down
2 changes: 1 addition & 1 deletion R/required_pkgs.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @param ... Not used.
#' @return A character vector
#' @name required_pkgs.model_spec
#' @examples
#' @examplesIf !parsnip:::is_cran_check()
#' should_fail <- try(required_pkgs(linear_reg(engine = NULL)), silent = TRUE)
#' should_fail
#'
Expand Down
Loading

0 comments on commit 2c5e1c8

Please sign in to comment.