i

R Programming Complete Tutorial

R Lists

Manage your List

A list is a data structure having components of mixed data types. Usually, a vector contains elements of the same type, but when we have elements of a different type is called a list.

Create a List

The list can be created using the list function, and denoting the contents works a lot like the C function, which have seen already in previous sections.

Create a list:

In this example, the variable X is a list containing three vectors, v1, v2, v3, and a numeric value of 3. The first variable v1 contains integer vector, 2nd one contains character vectors, and v3 is of type logical.So, this list contains elements of different data types.

Naming the list elements:

We can give names to the list elements, and they can be accessed using these names.We are giving the names to the elements of list X.The name of the first element is an Integer Vector.