On Mon, 9 Jun 2003, Jonck van der Kogel wrote:
Hi all,
I am having a bit of trouble with the array structure of R. What I want
to do is dynamically add/remove elements to an array. For example:
Let's say I have created an array:
myArray - array(c(3,8), dim=c(1,2))
myArray
[,1] [,2]
[1,]38
And I now want to, for example, push an element (5,6) on to this array
so it will read:
[,1] [,2]
[1,]38
[2,]56
And then pop the first element of the array so the array now reads:
[,1] [,2]
[1,]56
How would I do this? So far I've only read how to create an array if
you know the dimensions beforehand, but I've been unable to find how to
dynamically add/remove elements to/from an array.
I've figured out how to do this with lists and vectors, but not with
arrays. For this particular structure I need to work with arrays.
myArray - array(c(3,8), dim=c(1,2))
#add to the bottom
myArray - cbind(myArray, c(5,6))
# display the top
myArray
# remove the top
myArray - myArray[-1,]
-thomas
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help