R
stores data, and how that affects your workflowsEach piece of information is assigned of one class
Moving from highly-structured to less-structured
All elements in a vector are of an identical class
All elements in a vector are of an identical class
Vectors can be of any class introduced above
matrixName[rowNumber,columnNumber]
dataframe[rowNumber,columnNumber]
But we can also use the syntax dataframe$columnName
As with matrices and data frames, can extract individual vectors (columns or rows) by indexing the list
listName[[itemnumber]]
or listName$itemName
Tibbles are a modern take on data frames. They keep the features that have stood the test of time, and drop the features that used to be convenient but are now frustrating.
data.frame
s into tibble
s using as_tibble()
:R
can have row names, but tibbles can not.mtcars
dataset (inbuilt in R
)tibble
’s opinion: if it’s important, keep it as a column in your dataset.Example: print the mtcars
dataframe (in-built in R
)
Example: print mtcars
as a tibble
The exception to the rule: values of size one are recycled
What if we wanted one of our columns to have vectors in it?
We might be interested in generating linear models of body size against bill length
Or, we can use the power of tibbles:
Let’s do some exercises
For beginners: https://swcarpentry.github.io/r-novice-gapminder/13-dplyr.html
For intermediate: https://beck-lab.ucdavis.edu/tutorials/purrr.html
For advanced: https://adv-r.hadley.nz/oo.html
gklab/rr-2025/semester-project