Skip to content

how to append element at last position in array dynamically

3 messages · sagarnikam123, R. Michael Weylandt, jim holtman

#
You need to reassign the value of append back to h -- in more
technical terms, this is a pass-by-value rather than pass-by-reference
behavior:

h <- append(h, 9)

This is not likely to be efficient in production code, however.

Michael
On Tue, Feb 28, 2012 at 7:15 AM, sagarnikam123 <sagarnikam123 at gmail.com> wrote:
#
'append' returns a value that you have assign back to the object you
want, in this case 'h'

h <- append(h, 9)
On Tue, Feb 28, 2012 at 7:15 AM, sagarnikam123 <sagarnikam123 at gmail.com> wrote: