powered by
This function initializes a list based on size or names, with an optional initial value.
initList(x = NULL, initVal = NULL)
A list of the specified size and names, optionally initialized with a value.
A character vector as names, or an numeric indicating the size of the list.
an optional initial value for all elements of the list.
# Create a list with 3 elements initList(3) # Create a named list initialized with NULL initList(c("a", "b", "c")) # Create a list with 2 elements initialized with 0 initList(2, 0)
Run the code above in your browser using DataLab