Description Usage Arguments Details Value Examples
expandingList
is a fast implementation of a list that can be
dynamically appended to and turned into a standard R list
.
1 | expandingList(capacity = 10, envir = emptyenv())
|
capacity |
Initial list capacity or length. |
envir |
Environment. |
expandingList
is a
closure
that enables modification in place. It serves as an
object
in R.
The code is copied from Jan Kanis at http://stackoverflow.com/a/32870310.
A closure named expandingList with functions
expandingList$double.size
doubles the size of the list
expandingList$add
adds an element to the list
expandingList$as.list
converts the expandingList
into
a standard R list
1 2 3 4 5 | g <- expandingList(5) ## expandingList of length 5
for (i in 1:10) g$add(i) ## append to list without explicitly expanding
identical(1:10, unlist(g$as.list())) ## TRUE
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.