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"). How can I get the similar result when the y vector includes the only response variable (1 or 0) ? That is y <- c(1,1,1,0,0,1,0,1,0,0) Many thanks. -- View this message in context: http://r.789695.n4.nabble.com/indexing-tp4428210p4428746.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.