I'm an experienced programmer, but learning R is making me lose the little
hair I have left...

> list(NULL)
[[1]]
NULL

> length(list(NULL))
[1] 1
> x <- list()
> x[[1]] <- NULL
> x
list()
> length(x)
[1] 0


>From the above experiment, it is clear that, although one can create a
one-element list consisting of a NULL element, one can't get the same result
by assigning NULL to the first element of an empty list.  And it gets worse:

> x <- list(1, 2, 3)
> length(x)
[1] 3
> x[[2]] <- NULL
> length(x)
[1] 2



I just could NOT believe my eyes!  Am I going crazy???

What I'm trying to do is so simple and straightforward: I want to be able to
append NULL to a list, and, after the appending, have the last element of
the list be NULL.  Is that so unreasonable?  How can it be done?

TIA!

Kynn

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to