I am quite new to R and wrote a double for-loop that does exactly what I want (a block-bootstrap of index numbers with a certain block length). However, I am unable to store in a matrix what print(x_sample) shows me. I have tried lapply and everything else I could find here, but I was unable to solve the problem by myself. I really hope that you can help. Many thanks in advance
Here is my code: x <- c(1:1060,1,2,3) x_sample <- numeric(119*4) for (i in 1:3){ for (j in 0:119){ idx <- sample(1:1060,1,replace=TRUE) x_sample[(4*j+1):(4*j+4)] <- x[(idx):(idx+3)] } print(x_sample)}