[R] How to insert one element into a vector?
Thomas Lumley
tlumley at u.washington.edu
Mon Nov 22 17:10:54 CET 2004
On Mon, 22 Nov 2004, 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"!
Yes, this should be fixed.
> Python has separate insert and append methods for vectors.
I don't think this is a good idea unless there are efficiency issues.
You could always define one: the definition is fairly simple.
insert<-append
-thomas
More information about the R-help
mailing list