Re: [R] how to append element at last position in array dynamically

2012-02-28 Thread jim holtman
'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  wrote:
>> h<-array()
>> h
> [1] NA
>> append(h,9)
> [1] NA  9
>
> but what it append.
>> h
> [1] NA
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/how-to-append-element-at-last-position-in-array-dynamically-tp4427893p4427893.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to append element at last position in array dynamically

2012-02-28 Thread R. Michael Weylandt
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  wrote:
>> h<-array()
>> h
> [1] NA
>> append(h,9)
> [1] NA  9
>
> but what it append.
>> h
> [1] NA
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/how-to-append-element-at-last-position-in-array-dynamically-tp4427893p4427893.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] how to append element at last position in array dynamically

2012-02-28 Thread sagarnikam123
> h<-array()
> h
[1] NA
> append(h,9)
[1] NA  9

but what it append.
> h
[1] NA


--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-append-element-at-last-position-in-array-dynamically-tp4427893p4427893.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.