nimbleList: create a nimbleList

View source: R/nimbleList_core.R

nimbleListR Documentation

create a nimbleList


create a nimbleList from a nimbleList definition


  name = NA,
  predefined = FALSE,
  where = getNimbleFunctionEnvironment()



arbitrary set of names and types for the elements of the list or a single R list of type nimbleType.


optional character providing a name used internally, for example in generated C++ code. Usually this is left blank and NIMBLE provides a name.


logical for internal use only.


optional argument passed to setRefClass for where the reference class definition generated for this nimbleFunction will be stored. This is needed due to R package namespace issues but should never need to be provided by a user.


This function creates a definition for a nimbleList. The types argument defines the names, types, and dimensions of the elements of the nimbleList. Elements of nimbleLists can be either basic types (e.g., integer, double) or other nimbleList definitions. The types argument can be either a series of expressions of the form name = type(dim), or a list of nimbleType objects.

nimbleList returns a definition, which can be used to create instances of this type of nimbleList via the new() member function.

Definitions can be created in R's general environment or in nimbleFunction setup code. Instances can be created using the new() function in R's global environment, in nimbleFunction setup code, or in nimbleFunction run code.

Instances of nimbleList definitions can be used as arguments to run code of nimbleFunctions, and as the return type of nimbleFunctions.


NIMBLE development team


 exampleNimListDef <- nimbleList(x = integer(0), Y = double(2))
 nimbleListTypes <- list(nimbleType(name = 'x', type = 'integer', dim = 0),
                         nimbleType(name = 'Y', type = 'double', dim = 2))
 ## this nimbleList definition is identical to the one created above
 exampleNimListDef <- nimbleList(nimbleListTypes)

nimble documentation built on March 18, 2022, 8:03 p.m.