So here's the skinny:
Imagine a Rubik's Cube; it's 3x3x3. I happen to have an array that is a rubik's "cube" only it's 4x4xn. With n starting off as 1
When a certain condition in each 4x4 matrix within the array is true, then the matrix replicates itself; that is n grows by 1 (the array, or rubik's cube gets longer/ becomes a cuboid). Let's say, for each 4x4 matrix within the array, if [2,4] > [2,1], then the matrix replicates another version of itself within the array.
When that same certain condition in each 4x4 matrix within the array is false, then the matrix itself "dies" or erases itself out of existence. The array, or rubik's cube gets shorter. Let's say, for each 4x4 matrix within the array, if [2,4] < [2,1], then the matrix erases itself out of the array.
So I tried to build this into an array, and apparently you can't just add and drop matrices from an array at will.
I've been told you have to build a tensor - (from my conceptual model to what wikipedia says, it looks like this is a 2nd order stress tensor). I'm not a physics guy, and definitely not a math purists. I'm a basic applied mathematics guy (ORSA), but I don't have any kind of degree in that, just a few years experience doing "analysis".
Is it possible for anyone to please demonstrate for me how I might build this structure in R. I hope you understand that finding comprehensible/ conceptual information on how to build a tensor in R of the type I believe I'm writing about is incredibly difficult.
Thank you so very much for whatever assistance you can provide.
I am very grateful for it.
So here's some of what I've tried:
cells<-c(0,.4,0,0,.25,.6,.25,.5,4,12,4,10,20,0,0,0)
Mu<-matrix(cells, 4,4, byrow=TRUE)
Ma<-list(Mu)
for(i in Ma){
if(i[2,4] > i[2,1]){
j <-length(Ma) + 1
c[Ma, j<-Mu]
}else if(i[2,4] < i[2,1]){
Ma[[i]] <- NULL
}
}
}
This doesn't work.
Since you need to be able to add or remove 4*4 matrices from your array, it may be easier to use a list of 4*4 matrices, instead of an array.
If performance is an issue (the list is copied again and again), you may prefer to use an environment instead.
With your conditions for duplication and removal, this becomes: