* using log directory ‘/data/gannet/ripley/R/packages/tests-LENGTH1/SQB.Rcheck’ * using R Under development (unstable) (2022-04-26 r82260) * using platform: x86_64-pc-linux-gnu (64-bit) * using session charset: UTF-8 * using option ‘--no-stop-on-test-error’ * checking for file ‘SQB/DESCRIPTION’ ... OK * this is package ‘SQB’ version ‘0.4’ * package encoding: UTF-8 * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for executable files ... OK * checking for hidden files and directories ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking whether package ‘SQB’ can be installed ... [23s/68s] OK * checking package directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking R files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking whether the package can be unloaded cleanly ... OK * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking use of S3 registration ... OK * checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... [30s/78s] OK * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking LazyData ... NOTE 'LazyData' is specified without a 'data' directory * checking examples ... [11s/30s] ERROR Running examples in ‘SQB-Ex.R’ failed The error most likely occurred in: > ### Name: SQBreg > ### Title: SQBreg > ### Aliases: SQBreg > > ### ** Examples > > data(hills, package="MASS") > rt.df <- hills[sample(nrow(hills)),] > data.train <- rt.df[1 : (length(rt.df[, 1]) - 1), ] > data.test <- rt.df[-(1 : (length(rt.df[, 1]) - 1)),] > fit <- SQBreg(data.train, data.test, reps = 30, y = "time") | | | 0% ----------- FAILURE REPORT -------------- --- failure: length > 1 in coercion to logical --- --- srcref --- : --- package (from environment) --- SQB --- call from context --- SQBreg(data.train, data.test, reps = 30, y = "time") --- call from argument --- is.na(data.train) || is.na(data.test) --- R stacktrace --- where 1: SQBreg(data.train, data.test, reps = 30, y = "time") --- value of length: 102 type: logical --- x1 x2 y1 Ben Rha FALSE FALSE FALSE Greenmantle FALSE FALSE FALSE Half Ben Nevis FALSE FALSE FALSE Lairig Ghru FALSE FALSE FALSE Cairn Table FALSE FALSE FALSE Knock Hill FALSE FALSE FALSE Burnswark FALSE FALSE FALSE Black Hill FALSE FALSE FALSE Cockleroi FALSE FALSE FALSE Kildcon Hill FALSE FALSE FALSE Creag Dubh FALSE FALSE FALSE Traprain FALSE FALSE FALSE Meall Ant-Suidhe FALSE FALSE FALSE Ben Nevis FALSE FALSE FALSE Cow Hill FALSE FALSE FALSE Bens of Jura FALSE FALSE FALSE Scolty FALSE FALSE FALSE Eildon Two FALSE FALSE FALSE Ben Lomond FALSE FALSE FALSE Largo Law FALSE FALSE FALSE Cairngorm FALSE FALSE FALSE Two Breweries FALSE FALSE FALSE Seven Hills FALSE FALSE FALSE Lomonds FALSE FALSE FALSE Carnethy FALSE FALSE FALSE N Berwick Law FALSE FALSE FALSE Acmony FALSE FALSE FALSE Moffat Chase FALSE FALSE FALSE Creag Beag FALSE FALSE FALSE Criffel FALSE FALSE FALSE Cairnpapple FALSE FALSE FALSE Craig Dunain FALSE FALSE FALSE Knockfarrel FALSE FALSE FALSE Dollar FALSE FALSE FALSE --- function from context --- function (data.train, data.test, y, res, reps, cores, FunKDE, control, SQBalgorithm.1, SQBalgorithm.2, k, ncomp, nnet.size) { pb <- txtProgressBar(min = 0, max = 4, style = 3) data.train = data.train[, c(which(colnames(data.train) != y), which(colnames(data.train) == y))] data.test = data.test[, c(which(colnames(data.test) != y), which(colnames(data.test) == y))] mingzi <- paste("x", 1:length(data.train), sep = "") mingzi[length(mingzi)] <- "y1" colnames(data.train) <- mingzi colnames(data.test) <- mingzi formula <- y1 ~ . n.predictors = ncol(data.train) - 1 maxit <- nrow(data.train) index <- 1:maxit response <- n.predictors + 1 if (length(data.test) != length(data.train)) { stop("training and testing sets must have the same predictors and the same response") } if (missing(y)) stop("y is the response variable that must exist") if (!is.data.frame(data.train) || !is.data.frame(data.test)) stop("'Input datasets must be data frame") if (is.na(data.train) || is.na(data.test)) stop("NA must be removed from the data") if (length(data.train) != length(data.test)) stop("Unequal column length") if (missing(control)) { control = list(minsplit = 10, cp = 0) } if (missing(k)) { k = 1 } if (missing(nnet.size)) { nnet.size = 2 } if (nnet.size < 2) { warning("Invalid hidden layer or neuron, system modify to 2") nnet.size = 2 } if (missing(ncomp) || ncomp == 0 || n.predictors == 1) { ncomp = 1 } if (ncomp == n.predictors && n.predictors != 1) { ncomp = n.predictors - 1 } if (missing(res)) { res = round(maxit/2) } if (maxit <= res - 3) { warning("Function modifies the number of resampling that it is too close or over the training size.") res = maxit - 4 } if (missing(reps)) { reps = 100 } if (missing(SQBalgorithm.1)) { SQBalgorithm.1 = "lm" } if (missing(SQBalgorithm.2)) { SQBalgorithm.2 = "lm" } RegTree <- function(formula, data.train, res, index, SQBalgorithm, control, ...) { SQBalgorithm = SQBalgorithm.1 store <- double(maxit) for (i in index) { j <- index[i] subindex1 <- sample((1:maxit)[-j], res, replace = F) bootstrap.sample1 <- data.train[subindex1, ] if (SQBalgorithm == "CART") { fit1.step2.lm1 <- rpart(formula = formula, data = bootstrap.sample1, method = "anova", control = control) } if (SQBalgorithm == "lm") { fit1.step2.lm1 <- lm(formula = formula, data = bootstrap.sample1) } if (SQBalgorithm == "KNN") { fit1.step2.lm1 <- knnreg(formula = formula, data = bootstrap.sample1, k = k) } if (SQBalgorithm == "nnet") { fit1.step2.lm1 <- nnet(formula = formula, size = nnet.size, data = bootstrap.sample1, linout = T, trace = F) } if (SQBalgorithm == "PCR") { fit1.step2.lm1 <- pcr(formula, data = bootstrap.sample1, scale = TRUE, validation = "CV") } pred.lm <- as.numeric(predict(fit1.step2.lm1, newdata = data.train[j, ], ncomp = ncomp)) store[i] <- pred.lm } store } setTxtProgressBar(pb, 1) if (missing(cores) || cores == 1) { cores = F res.replicate <- replicate(reps, RegTree(formula = formula, data.train, res = res, index = index, SQBalgorithm = SQBalgorithm.1)) } else if (1 < cores & cores < 1 + getOption("mc.cores", parallel::detectCores())) { res.replicate <- mclapply(1:reps, function(itr) { RegTree(formula = formula, data.train, res = res, index = index, SQBalgorithm = SQBalgorithm.1) }, mc.cores = cores) res.replicate <- matrix(unlist(res.replicate), ncol = reps) } else if (cores == "maxcores") { cores = getOption("mc.cores", parallel::detectCores()) res.replicate <- mclapply(1:reps, function(itr) { RegTree(formula = formula, data.train, res, index = index, SQBalgorithm = SQBalgorithm.1) }, mc.cores = cores) res.replicate <- matrix(unlist(res.replicate), ncol = reps) } else if (cores > getOption("mc.cores", parallel::detectCores()) || cores < 1 || cores%%1 != 0) { stop("The use number of cores is invalid") } setTxtProgressBar(pb, 2) new.reg.lm100 <- res.replicate setTxtProgressBar(pb, 3) if (missing(FunKDE) || FunKDE == "gaussian") { FunKDE = function(new.reg.lm100, reps, SIGMA) { if (missing(SIGMA)) { SIGMA <- 1 } c <- 1/sqrt(1 + SIGMA^2) sigma.hat <- apply(new.reg.lm100, 1, sd) meanMatrix <- matrix(rep(rowMeans(new.reg.lm100), reps), ncol = reps) sdMatrix <- matrix(rep(sigma.hat, reps), ncol = reps) Zi <- matrix(rnorm(length(sdMatrix), 0, SIGMA), ncol = reps) norm.generator150 <- meanMatrix + c * (new.reg.lm100 - meanMatrix + sdMatrix * Zi) return(norm.generator150) } } else if (FunKDE == "logistic") { FunKDE = function(new.reg.lm100, reps, SIGMA) { if (missing(SIGMA)) { SIGMA <- sqrt(pi^2/3) } c <- 1/sqrt(1 + SIGMA^2) meanMatrix <- matrix(rep(rowMeans(new.reg.lm100), reps), ncol = reps) sdMatrix <- matrix(rep(apply(new.reg.lm100, 1, sd), reps), ncol = reps) Zi <- matrix(rlogis(length(sdMatrix), 0, SIGMA), ncol = reps) norm.generator150 <- meanMatrix + c * (new.reg.lm100 - meanMatrix + sdMatrix * Zi) return(norm.generator150) } } else if (FunKDE == "rectangle") { FunKDE = function(new.reg.lm100, reps, SIGMA) { if (missing(SIGMA)) { SIGMA <- sqrt(1/3) } c <- 1/sqrt(1 + SIGMA^2) sigma.hat <- apply(new.reg.lm100, 1, sd) meanMatrix <- matrix(rep(rowMeans(new.reg.lm100), reps), ncol = reps) sdMatrix <- matrix(rep(apply(new.reg.lm100, 1, sd), reps), ncol = reps) Zi <- matrix(runif(length(sdMatrix), -1, 1), ncol = reps) norm.generator150 <- meanMatrix + c * (new.reg.lm100 - meanMatrix + sdMatrix * Zi) return(norm.generator150) } } else if (FunKDE == "normal") { KDE100.generator150 = matrix(0, nrow = nrow(new.reg.lm100), ncol = ncol(new.reg.lm100)) FunKDE = function(new.reg.lm100, reps, SIGMA) { SIGMA = NULL reps = reps sigma.hat <- apply(new.reg.lm100, 1, sd) mean.hat <- rowMeans(new.reg.lm100) for (iteration in 1:nrow(new.reg.lm100)) { KDE100.generator150[iteration, ] <- rnorm(reps, mean.hat[iteration], sigma.hat[iteration]) } return(KDE100.generator150) } } else if (FunKDE == "uniform") { KDE100.generator150 = matrix(0, nrow = nrow(new.reg.lm100), ncol = ncol(new.reg.lm100)) FunKDE = function(new.reg.lm100, reps, SIGMA) { SIGMA = NULL reps = reps min.hat <- apply(new.reg.lm100, 1, min) max.hat <- apply(new.reg.lm100, 1, max) for (iteration in 1:nrow(new.reg.lm100)) { KDE100.generator150[iteration, ] <- runif(reps, min.hat[iteration], max.hat[iteration]) } return(KDE100.generator150) } } else if (FunKDE == "logis") { KDE100.generator150 = matrix(0, nrow = nrow(new.reg.lm100), ncol = ncol(new.reg.lm100)) FunKDE = function(new.reg.lm100, reps, SIGMA) { SIGMA = NULL reps = reps mean.hat <- apply(new.reg.lm100, 1, mean) scale.hat <- apply(new.reg.lm100, 1, sd) for (iteration in 1:nrow(new.reg.lm100)) { KDE100.generator150[iteration, ] <- rlogis(reps, mean.hat[iteration], scale.hat[iteration]) } return(KDE100.generator150) } } else { stop("response generator invalid, should select: 'normal', 'uniform', 'logis',\n 'gaussian', 'rectangle', 'logistic'. ") } KDE100.generator150 <- FunKDE(new.reg.lm100, reps) KDEtraining.newL <- data.frame(data.train[, -length(data.train), drop = FALSE], KDE100.generator150) KDE.fit <- matrix(0, nrow = nrow(data.test) + nrow(data.train) - maxit, ncol = reps) if (SQBalgorithm.2 == "CART") { for (i in (n.predictors + 1):(reps + n.predictors)) { gongshi.KDE <- as.formula(paste("KDEtraining.newL[, i] ~", paste(attr(terms.formula(formula, data = data.train), "term.labels"), sep = "", collapse = "+"))) KDE.model <- rpart(formula = gongshi.KDE, data = KDEtraining.newL, method = "anova") KDE.fit[, i - n.predictors] <- predict(KDE.model, newdata = data.test) } } if (SQBalgorithm.2 == "lm") { for (i in (n.predictors + 1):(reps + n.predictors)) { gongshi.KDE <- as.formula(paste("KDEtraining.newL[, i] ~", paste(attr(terms.formula(formula, data = data.train), "term.labels"), sep = "", collapse = "+"))) KDE.model <- lm(formula = gongshi.KDE, data = KDEtraining.newL) KDE.fit[, i - n.predictors] <- predict(KDE.model, newdata = data.test) } } if (SQBalgorithm.2 == "KNN") { for (i in (n.predictors + 1):(reps + n.predictors)) { gongshi.KDE <- as.formula(paste("KDEtraining.newL[, i] ~", paste(attr(terms.formula(formula, data = data.train), "term.labels"), sep = "", collapse = "+"))) KDE.model <- knnreg(formula = gongshi.KDE, data = KDEtraining.newL, k = k) KDE.fit[, i - n.predictors] <- predict(KDE.model, newdata = data.test) } } if (SQBalgorithm.2 == "nnet") { for (i in (n.predictors + 1):(reps + n.predictors)) { gongshi.KDE <- as.formula(paste("KDEtraining.newL[, i] ~", paste(attr(terms.formula(formula, data = data.train), "term.labels"), sep = "", collapse = "+"))) KDE.model <- nnet(formula = gongshi.KDE, data = KDEtraining.newL, size = nnet.size, linout = T, trace = F) KDE.fit[, i - n.predictors] <- as.numeric(predict(KDE.model, newdata = data.test)) } } if (SQBalgorithm.2 == "PCR") { for (i in (n.predictors + 1):(reps + n.predictors)) { gongshi.KDE <- as.formula(paste("KDEtraining.newL[, i] ~", paste(attr(terms.formula(formula, data = data.train), "term.labels"), sep = "", collapse = "+"))) KDE.model <- pcr(formula = gongshi.KDE, data = KDEtraining.newL, scale = TRUE, validation = "CV") KDE.fit[, i - n.predictors] <- as.numeric(predict(KDE.model, newdata = data.test, ncomp = ncomp)) } } KDE.fit <- as.data.frame(KDE.fit) final.prediction <- rowMeans(KDE.fit) setTxtProgressBar(pb, 4) return(final.prediction) } --- function search by body --- Function SQBreg in namespace SQB has this body. ----------- END OF FAILURE REPORT -------------- Fatal error: length > 1 in coercion to logical * checking PDF version of manual ... OK * checking for non-standard things in the check directory ... OK * checking for detritus in the temp directory ... OK * DONE Status: 1 ERROR, 1 NOTE See ‘/data/gannet/ripley/R/packages/tests-LENGTH1/SQB.Rcheck/00check.log’ for details. Command exited with non-zero status 1 Time 8:07.98, 167.35 + 17.37