Let's perform the following steps to create a list:
The list()R function is used to create a list object. The dimension of a list could be any, and it can contain heterogeneous objects. To create a list called listA, execute the following code:
listA <- list(cVec, nVec, Lvec, matA, datA, arrayA)
The list could be a named list or without a name. To create a named list, the syntax is similar to the creation of a named vector. Here is an example:
The list preserves the original properties of the elements. To check the properties at a glance, you can use the str() function as follows:
str(listA) str(listB)
The preceding function will then provide the output of the number of elements of the list, data types of each of the components, and the name of each component (if there is any), along with few values of the components, as follows: