4

It seems R internally implements lists as vectors. "Lists are VECSXP [...]" -- R internals.

That is, lists are generic vectors.

Generic vectors must be vectors containing pointers to their elements instead of storing the elements themselves in the vector position. This creates a vector that can store any element in it, hence the term "generic". (Assuming this proceeds, ...)

So lists can be represented by generic vectors. What happens when I want to append a new element to a list (which is internally a vector) whose internal vector doesn't have any more space for a new element? Is the vector reallocated?

Related question: Why does is.vector() return TRUE for list?

R. Chopin
  • 141
  • 4
  • 3
    Maybe related/dupe: https://stackoverflow.com/a/16129466 (and if the question transforms into one of performance, maybe https://stackoverflow.com/questions/17046336/here-we-go-again-append-an-element-to-a-list-in-r) – Frank Sep 26 '18 at 18:14
  • Possible duplicate of [What is the internal implementation of lists?](https://stackoverflow.com/questions/16129068/what-is-the-internal-implementation-of-lists) – user2554330 Sep 26 '18 at 20:15

0 Answers0