I am trying to save the data from a loop of logical tests.
So I have the following data:
T1 <- matrix(seq(from=100000, to=6600000,length.out=676),
Another way to do what joran suggests is to use the apply family of functions.
result2 <- lapply(F, function(f) {T1 > f})
This gives the same thing as joran's result
, a list where each element corresponds to one of the values of F
and that element is a 26x26 logical matrix.
Another alternative is to store the results as a three dimensional logical matrix (49*26*26) where each slice corresponds to one of the values of F
.
result3 <- sapply(F, function(f) {T1 > f}, simplify="array")
the structure of which is
> str(result3)
logi [1:26, 1:26, 1:49] FALSE FALSE FALSE FALSE TRUE TRUE ...
Store each boolean matrix as an item in a list:
result <- vector("list",49)
for (i in 1:49)
{
result[[i]] <- T1>F[i] # I used print to see the results in the screen
}
#Print the first matrix on screen
result[[1]]