[R] indexing??

helin_susam helin.susam at gmail.com
Tue Feb 28 14:59:24 CET 2012


Hello All,

My algorithm as follows;
y <- c(1,1,1,0,0,1,0,1,0,0)
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]
}

I tried to find the total of the two vectors as statistic by using
bootstrap. Finally, I want to get the values which do not contain the y's
each elemet. In the algorithm ti is referred to "ff". But i get always the
same result ;
> ff
list()
> kk
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
Because, my "y" vector contains only 2 elements, and probably all of the
bootstrap resamples  include "1", or all of resamples include "0". So I can
not find the true matches. Can anyone help me about how to be?
Thanks.

--
View this message in context: http://r.789695.n4.nabble.com/indexing-tp4428210p4428210.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list