[R] Appending elements to an array
Jonck van der Kogel
jonck at vanderkogel.net
Mon Jun 9 22:45:45 CEST 2003
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,] 3 8
And I now want to, for example, push an element (5,6) on to this array
so it will read:
[,1] [,2]
[1,] 3 8
[2,] 5 6
And then pop the first element of the array so the array now reads:
[,1] [,2]
[1,] 5 6
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.
Any help on how to do something like this would be much appreciated.
Thanks, Jonck
More information about the R-help
mailing list