How to insert one element into a vector?
On Mon, 2004-11-22 at 17:43, Barry Rowlingson wrote:
Deepayan Sarkar wrote:
Pretty much what 'append' does.
A shame then, that help.search("insert") doesn't find 'append'! I cant
think why anyone looking for a way of _inserting_ a value in the middle
of a vector would think of looking at "append"!
Python has separate insert and append methods for vectors.
>>> x=[1,2,3,4,6] >>> x.insert(4,5) >>> x
[1, 2, 3, 4, 5, 6]
>>> x.append(99) >>> x
[1, 2, 3, 4, 5, 6, 99]
So has R. R's 'insert' is called 'append', and R's 'append' is called 'c'. Counter-intuitively though, and I'm happy that Peter Dalgaard didn't know that 'append' inserts: it gives some hope to us ordinary mortals. cheers, jazza
Jari Oksanen <jarioksa at sun3.oulu.fi>