[Analogue-commits] r251 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Feb 9 13:41:40 CET 2012
Author: gsimpson
Date: 2012-02-09 13:41:40 +0100 (Thu, 09 Feb 2012)
New Revision: 251
Modified:
pkg/R/bootstrap.R
pkg/R/crossval.R
pkg/R/internal.R
pkg/R/predict.wa.R
Log:
replace .Internal(sample(...)) usage with sample.int()
Modified: pkg/R/bootstrap.R
===================================================================
--- pkg/R/bootstrap.R 2012-01-11 14:29:38 UTC (rev 250)
+++ pkg/R/bootstrap.R 2012-02-09 12:41:40 UTC (rev 251)
@@ -54,9 +54,7 @@
for(i in 1:n.boot)
{
## draw a bootstrap sample of size n.train
- ##samp.boot <- sample(1:n.train, replace = TRUE)
- samp.boot <- .Internal(sample(n.train, n.train,
- replace = TRUE, prob = NULL))
+ samp.boot <- sample.int(n.train, n.train, replace = TRUE)
## store the unique values for subsetting later
samp.test <- unique(samp.boot)
## subset the env data for training set
@@ -373,4 +371,3 @@
cat("\n")
invisible(x)
}
-
Modified: pkg/R/crossval.R
===================================================================
--- pkg/R/crossval.R 2012-01-11 14:29:38 UTC (rev 250)
+++ pkg/R/crossval.R 2012-02-09 12:41:40 UTC (rev 251)
@@ -49,7 +49,7 @@
if(verbose)
setTxtProgressBar(pb, i)
## do a k-fold CV
- pind <- ind[.Internal(sample(N, N, TRUE, NULL))]
+ pind <- ind[sample.int(N, N, replace = FALSE)] ## sure this should be replace = FALSE
for(k in seq_len(nfold)) {
sel <- pind == k ## sel is samples in leave out group
N.oob <- sum(sel) ## N in leave out group
@@ -78,7 +78,7 @@
for(i in seq_len(nboot)) {
if(verbose)
setTxtProgressBar(pb, i)
- bSamp <- .Internal(sample(N, N, TRUE, NULL))
+ bSamp <- sample.int(N, N, replace = TRUE)
sel <- which(!ind %in% bSamp) ## need indices!!!
N.oob <- NROW(X[sel, , drop = FALSE])
N.mod <- N - N.oob
Modified: pkg/R/internal.R
===================================================================
--- pkg/R/internal.R 2012-01-11 14:29:38 UTC (rev 250)
+++ pkg/R/internal.R 2012-02-09 12:41:40 UTC (rev 251)
@@ -226,7 +226,6 @@
## coef[1] + x * coef[2]
##}
-
## w.tol --- computes weighted standard deviations AKA tolerances
w.tol <- function(x, env, opt, useN2 = TRUE) {
## x = species abundances
Modified: pkg/R/predict.wa.R
===================================================================
--- pkg/R/predict.wa.R 2012-01-11 14:29:38 UTC (rev 250)
+++ pkg/R/predict.wa.R 2012-02-09 12:41:40 UTC (rev 251)
@@ -98,8 +98,7 @@
flush.console()
}
## bootstrap sample
- sel <- .Internal(sample(n.train, n.train,
- TRUE, NULL))
+ sel <- sample.int(n.train, n.train, replace = TRUE)
nr <- NROW(X[sel, , drop = FALSE]) ## number of samples
nr.oob <- NROW(X[-sel, , drop = FALSE])
wa.optima <- w.avg(X[sel,,drop = FALSE], ENV[sel])
More information about the Analogue-commits
mailing list