INTRODUCTION TO PROGRAMMING IN R > MISSION 4 > LISTS IN R
Working With Lists
In the lessons, Working with Vectors and Working with Matrices, you learned that vectors and matrices can only hold a single data type. As you proceed with your data analysis journey, you will realize this is a significant limitation, since many data sets include columns with different data types. Thankfully, there’s an answer for this in R: lists.
In this lesson, you will learn how to work with data stored in lists, which can contain multiple types of objects. The objects may consist of different data structures, including single data elements, vectors, and matrices. Storing objects in lists allows us to make use of some powerful R features for performing the same operation on each object in your list, which can help you avoid having to perform that repetition manually.
In addition to learning what lists are and the anatomy of a list, in this lesson, you will also learn how to: assign names to list objects, modify elements, add elements, and combine lists.
After you finish this lesson, you will be well-equipped to start building simple programs in R; what you build is limited by the depth of your imagination. If you have trouble coming up with ideas, you can practice by following this tutorial to build a simple calculator and maybe some additional ideas for programs will come to mind.
1. Lists: Objects That Can Contain Multiple Data Types
2. Anatomy of a List
3. Assigning Names to List Objects
4. Indexing Lists
5. Modifying List Elements
6. Adding Elements to Lists
7. Combining Lists
8. Next Steps