Lists are objects that can hold many elements of different data types. Unlike vectors, lists don't have to be homogeneous – that is, they can have elements with different data types.
Take a look at this example:
This object is called a list. It contains seven members. Unlike the elements of vectors, the elements of lists do not have to be of the same type. This list contains character objects (name
, country
, profession
, and applied_position
), numbers (age
), a vector (language
), and even a data frame (prior_working_experience
).
Unlike data frames (where each column needs to be of the same length), lists don't require that their members be of the same length. For example, the element name
has a length of one, the element language
has a length of three, and the element prior_working_experience
has a length of three rows and three columns. Lists are flexible. As such, they're great for storing unstructured data.