3) Lists and Matrices
π Lecture
This week in class we discuss R lists, which are the most generic kind of data container in R. You will learn:
- in what sense a list is a non-atomic atomic
- in what sense a list is a one-dimensional object
- how to create lists
- practice manipulating lists
π Reading
Read chapters 6, 7 and 8 of βR Coding Basicsβ:
π¬ Lab
In addition to lists, in lab you will also learn about matrices in R. You will work creating and manipulating more atomic objects such as matrices, and also non-atomic lists.
π― Objectives
- Create simple matrices with
matrix()
- Describe and give examples of matrix subsetting (subscripting, indexing)
- Explain in what sense a matrix is a 2-dimensional object
- Describe and give examples of subsetting (subscripting, indexing) of an R list
- Provide an example of list subsetting with single brackets (e.g.
lis[index]
) - Provide an example of list subsetting with double brackets, and a single element (e.g.
lis[[index]]
) - Provide a manipulation example of a list with the dollar operator (e.g.
lis$wagon
)
π Shiny Friday
The shiny app of this week is based on the computation of Future Value (compounding interest) in its simplest version:
\[ FV = P (1 + r)^n \]
This is a simple app that takes three inputs:
- P = principal or initial amount (how much you deposit)
- r = annual interest rate (or rate of return)
- n = number of years
In turn, the app produces one (graphical) output which is a timeline to visualize the Future Value.
There are two versions of the app: one uses three sliders (one slider per input), and the other one uses three numeric inputs (one number per input)
π HW Assignments
- HW1 due this 02/02
- HW2 released on 02/03, due 02/09