Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Introduction to lists
Accessing list elements
Unnamed lists
Working with lists
Summary

Instruction

Great! So far, you've learned that [[...]] can be used to access any one (and only one) list member directly.

If that member happens to be a data structure, like a vector, then it likely contains more than just a single value. For example,

candidate[["language"]]

returns a vector of three values: English, Dutch, and French. How do we access each of these values individually?

We can use the vector indexing operator, []. For example,

candidate[["language"]][1]

will return English,

candidate[["language"]][2]

will return Dutch, and

candidate[["language"]][3]

will return French.

To better understand this process, break it down into two steps: First, you retrieve the member from the list. Once you have that member, and you know its type, use the appropriate operator to retrieve its values. For example, if the list member happens to be a data frame, then use either the $ notation or the [row, col] notation to retrieve its members.

Exercise

Display the name of the company where Emma currently works.

Prior working experience information is stored in a data frame. This data frame happens to be a member of the candidate list. The first row of data contains information for the most recent position a candidate holds.

Stuck? Here's a hint!

Type:

candidate[["prior_working_experience"]][1, "company"]