[R] appending to a list
David Winsemius
dwinsemius at comcast.net
Mon Sep 6 05:36:40 CEST 2010
On Sep 5, 2010, at 10:11 PM, Aks Ism wrote:
> No, I mean dynamically. Like list.push_back
Not sure what you mean by "dynamically" and my Google search for the
unspecified function list.push_back uncovered a C++ function that is
at least as complex as what I believe would be the equivalent R
function. I think you need to expand your discussion and your
executable R examples before people are going to understand what you
are thinking (....but not writing).
mylist <- c(mylist, my.element)
c() simply adds an element and R requires that you assign it if it is
to be preserved.
Perhaps you mean something like this:
ll <- list();
for (i in 1:20) {
my.element <- scan();
ll <- c(ll, my.element);
if (is.na(my.element)){return(ll);break}}
--
David.
>
> On Mon, Sep 6, 2010 at 1:01 AM, David Winsemius <dwinsemius at comcast.net
> > wrote:
>
> On Sep 5, 2010, at 1:21 PM, Aks Ism wrote:
>
> Hi,
>
> I've looked at previous discussions and did not get anything. I want
> to be
> able to append to a list in a loop. Is this possible?
>
> Of course:
>
> ?"c"
>
> ?"[["
>
> --
> David Winsemius, MD
> West Hartford, CT
>
>
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list