Lists
- Slides for this lesson
- Demo script for this lesson
- Use the folder that contains the unzipped Rdata folder as working directory
Why make a list?
Lists are created:
- when you split() a data frame in subsets of different sizes e.g. split mtcars into 3 data frames: cars with 4, 6 or 8 gears. Storing these 3 data frames as objects in a list allows you to manipulate them all in the same way.
- R generates lists the whole time: e.g. when you save a plot or the results of a statistical tests in a variable, that variable will be a list.
- to keep different types of info together e.g. EdgeR stores RNASeq data in a list that contains a matrix with the counts, a data frame with sample annotation, a data frame with gene annotation, a vector with normalization factors….