On Tue, Feb 28, 2012 at 08:50:45AM -0800, helin_susam wrote: > Dear Petr Pikal and Petr Savicky thank you for your replies.. > > If the y vector contains different elements my algorithm gives this result; > y <- c(1,2,3,4,5,6,7,8,9,10) > x <- c(1,0,0,1,1,0,0,1,1,0) > > n <- length(x) > > t <- matrix(cbind(y,x), ncol=2) > > z = x+y > > for(j in 1:length(x)) { > out <- vector("list", ) > > for(i in 1:10) { > > t.s <- t[sample(n,n,replace=T),] > > y.s <- t.s[,1] > x.s <- t.s[,2] > > z.s <- y.s+x.s > > out[[i]] <- list(ff <- (z.s), finding=any (y.s==y[j])) > kk <- sapply(out, function(x) {x$finding}) > ff <- out[! kk] > } > } > > > kk > [1] TRUE TRUE TRUE TRUE FALSE TRUE TRUE TRUE TRUE FALSE > > ff > [[1]] > [[1]][[1]] > [1] 5 7 3 2 2 6 7 2 6 6 > > [[1]]$finding > [1] FALSE > > > [[2]] > [[2]][[1]] > [1] 7 10 6 2 2 2 6 6 9 3 > > [[2]]$finding > [1] FALSE > > Here, the two situations are FALSE, that is 5th and 10th bootstrap > re-samples do not contain one (or more) element(s) of original vector ("y").
Hi. Your code generates a new list "out" for each j. This means that you generate a list "out", test the presence of y[1] in its components, then delete "out", replace it by a new list and test the presence of y[2] in this new list, then "out" is deleted and replaced by another "out", etc. This is probably not, what you want. Is this correct? Petr Savicky. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.