Learn R Programming

nimble (version 1.2.1)

nimbleList: create a nimbleList

Description

create a nimbleList from a nimbleList definition

Usage

nimbleList(
  ...,
  name = as.character(NA),
  predefined = FALSE,
  where = getNimbleFunctionEnvironment()
)

Arguments

...

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

name

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

predefined

logical for internal use only.

where

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.

Author

NIMBLE development team

Details

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.

Examples

Run this code
 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)

Run the code above in your browser using DataLab