From e44cea134cd963f3d466d8e34bdf4274eafa5f68 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sun, 21 Apr 2024 19:15:13 -0700 Subject: [PATCH] seq(length=) --- pkg/caret/R/classDist.R | 2 +- pkg/caret/R/createDataPartition.R | 4 ++-- pkg/caret/R/gafs.R | 2 +- pkg/caret/R/lift.R | 2 +- pkg/caret/R/misc.R | 6 +++--- pkg/caret/R/twoClassSim.R | 2 +- pkg/caret/tests/testthat/test_resamples.R | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/caret/R/classDist.R b/pkg/caret/R/classDist.R index 98ae1563e..cbe1fd3d8 100644 --- a/pkg/caret/R/classDist.R +++ b/pkg/caret/R/classDist.R @@ -75,7 +75,7 @@ classDist.default <- function(x, y, groups = 5, if(is.numeric(y)) { y <- cut(y, - unique(quantile(y, probs = seq(0, 1, length = groups + 1))), + unique(quantile(y, probs = seq(0, 1, length.out = groups + 1))), include.lowest = TRUE) classLabels <- paste(round((1:groups)/groups*100, 2)) y <- factor(y) diff --git a/pkg/caret/R/createDataPartition.R b/pkg/caret/R/createDataPartition.R index 9c31f2f14..4eb78cf4a 100644 --- a/pkg/caret/R/createDataPartition.R +++ b/pkg/caret/R/createDataPartition.R @@ -116,7 +116,7 @@ createDataPartition <- function (y, times = 1, p = 0.5, list = TRUE, groups = mi if(is.numeric(y)) { y <- cut(y, - unique(quantile(y, probs = seq(0, 1, length = groups))), + unique(quantile(y, probs = seq(0, 1, length.out = groups))), include.lowest = TRUE) } else { xtab <- table(y) @@ -180,7 +180,7 @@ createDataPartition <- function (y, times = 1, p = 0.5, list = TRUE, groups = mi cuts <- floor(length(y)/k) if(cuts < 2) cuts <- 2 if(cuts > 5) cuts <- 5 - breaks <- unique(quantile(y, probs = seq(0, 1, length = cuts))) + breaks <- unique(quantile(y, probs = seq(0, 1, length.out = cuts))) y <- cut(y, breaks, include.lowest = TRUE) } diff --git a/pkg/caret/R/gafs.R b/pkg/caret/R/gafs.R index acee07396..96bcc76d7 100644 --- a/pkg/caret/R/gafs.R +++ b/pkg/caret/R/gafs.R @@ -136,7 +136,7 @@ ga_func_check <- function(x) { #' @export gafs_initial gafs_initial <- function (vars, popSize, ...) { x <- matrix(NA, nrow = popSize, ncol = vars) - probs <- seq(.9, .1, length = popSize) + probs <- seq(.9, .1, length.out = popSize) for(i in 1:popSize){ x[i,] <- sample(0:1, replace = TRUE, size = vars, diff --git a/pkg/caret/R/lift.R b/pkg/caret/R/lift.R index 8cb814845..e397750b3 100644 --- a/pkg/caret/R/lift.R +++ b/pkg/caret/R/lift.R @@ -233,7 +233,7 @@ liftCalc <- function(x, class = levels(x$liftClassVar)[1], cuts = NULL) { baseline <- mean(x$liftClassVar == class) if(!is.null(cuts)) { if(length(cuts) == 1) { - cuts <- rev(seq(0, 1, length = cuts)) + cuts <- rev(seq(0, 1, length.out = cuts)) } else { cuts <- unique(c(1, sort(cuts, decreasing = TRUE), 0)) } diff --git a/pkg/caret/R/misc.R b/pkg/caret/R/misc.R index 4b6db9f04..6e5c1f225 100644 --- a/pkg/caret/R/misc.R +++ b/pkg/caret/R/misc.R @@ -400,10 +400,10 @@ var_seq <- function(p, classification = FALSE, len = 3) { } else { if(p <= len) { - tuneSeq <- floor(seq(2, to = p, length = p)) + tuneSeq <- floor(seq(2, to = p, length.out = p)) } else { - if(p < 500 ) tuneSeq <- floor(seq(2, to = p, length = len)) - else tuneSeq <- floor(2^seq(1, to = log(p, base = 2), length = len)) + if(p < 500 ) tuneSeq <- floor(seq(2, to = p, length.out = len)) + else tuneSeq <- floor(2^seq(1, to = log(p, base = 2), length.out = len)) } } if(any(table(tuneSeq) > 1)) { diff --git a/pkg/caret/R/twoClassSim.R b/pkg/caret/R/twoClassSim.R index a2e9bb4ce..a78a1bcfd 100644 --- a/pkg/caret/R/twoClassSim.R +++ b/pkg/caret/R/twoClassSim.R @@ -202,7 +202,7 @@ twoClassSim <- function(n = 100, 2*sin(pi*tmpData$Nonlinear2* tmpData$Nonlinear3) if(linearVars > 0) { - lin <- seq(10, 1, length = linearVars)/4 + lin <- seq(10, 1, length.out = linearVars)/4 lin <- lin * rep(c(-1, 1), floor(linearVars)+1)[1:linearVars] for(i in seq(along.with = lin)) lp <- lp + tmpData[, i+3]*lin[i] } diff --git a/pkg/caret/tests/testthat/test_resamples.R b/pkg/caret/tests/testthat/test_resamples.R index d97d516ef..1d3629ec4 100644 --- a/pkg/caret/tests/testthat/test_resamples.R +++ b/pkg/caret/tests/testthat/test_resamples.R @@ -41,7 +41,7 @@ test_that('resample calculations', { test_that('test group-k-fold', { get_data <- function(n = 500) { - prevalence <- seq(.1, .9, length = 26) + prevalence <- seq(.1, .9, length.out = 26) dat <- sample(letters, size = n, replace = TRUE, prob = sample(prevalence)) data.frame(grp = dat, stringsAsFactors = TRUE) }