2
About the question in:
I need to access my matrix in parts (because the procedure generates a problem with the available memory limit for R, given the large size of my initial matrix --500 columns, size 200-). For example:
for(j in 1:100){
set.seed(1234)
res2 <- lapply(seq_len(nBS), function(i) apply(dados[,j,drop=F], 2, sample, n, TRUE))
}
When I do that, just the column j = 100
is used.
How do I use all vectors of my matrix in this for loop (from 1 to 100)?
Any suggestions to do this more efficiently for the 500 columns?
Thank you in advance!
set.seed
out of cyclefor
. 2) Initializeres2 <- vector("list", 100)
also outside the cycle. 3) Inside the cycle,res2[[j]] <- lapply(etc)
.– Rui Barradas
function(i) apply(dados[, 1:100], etc)
. If you do this you don’t need to initialize the variableres2
as I said in point 2) above. It is to do exactly as it is in that response only with the difference of the dataset that will become a subset of the databasedados
. After processing this subset, you can repeat withdados[, 101:200]
etc up to all 500 columns.– Rui Barradas
Thanks!! The solution 4) is great!
– user157038