I have an array of dimensions:
> dim(filtro1)
[1] 2806519 31
I need to remove rows from this array that meet a condition. So far so good. However, the computationally looping for this has been very expensive (time consuming - 8 to 10 hours). I've tried rbind, but this is slower than the solution below:
for(i in 1:length(filtro1[,1])){
if(filtro1[i,31] == 0){
filtro1 <- filtro1[-i,]
print(i)
}
}
- print (i) is just for me to follow the loop execution
I tried running the code in parallel with foreach and% dopar%, but apparently it does not work because the reasoning above depends on the index
Does anyone know how to do the removal of array rows faster and more efficiently?