sagarnikam123
2012-Feb-28 12:15 UTC
[R] how to append element at last position in array dynamically
> 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. Michael Weylandt
2012-Feb-28 14:26 UTC
[R] how to append element at last position in array dynamically
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:>> 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 at 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
2012-Feb-28 14:33 UTC
[R] how to append element at last position in array dynamically
'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:>> 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 at 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.
Apparently Analagous Threads
- how to make hash?& append element, if i want following condition
- appending variable's values in table like fashion
- want to drop levels of table vector & join two vector(appending)
- How to get the value of last element in a vector/array ?
- ragged array with append