Video Notes
Multi-Dimensional Data Structures
For two or more dimensions, R provides matrices, arrays, lists, and data frames.
Of these, data frames are the most common and useful for working with datasets.
A data frame is a two-dimensional table-like structure where:
- Each column is a vector
- All columns are the same length
- Columns can hold different data types (numeric, character, logical, etc.)
Example:
results <- data.frame(
id = 1:3,
name = c("Alice", "Bob", "Charlie"),
score = c(85.5, 92.0, 88.5)
)
FYI
The syntax 1:3 uses the sequence operator (:) to generate a vector of consecutive integers.
You can access columns from a data frame using the list extraction operator ($):
results$name # print(my_data$name) # [1] "Alice" "Bob" "Charlie"
mean(results$score) # 88.66667
Exploring Data Frames
Here are some helpful functions for inspecting a data frame:
print(my_data) # Prints the full data frame
str(my_data) # Compact summary of structure, types, and sample values
head(my_data) # First 6 rows
tail(my_data) # Last 6 rows
In Summary
Data types define what kind of data you have.
Data structures define how that data is organized.
Together, they form the foundation for everything you’ll do in R.
Unlock all notes for $4
For $4, you’ll get 6 months of unlimited access to the notes for the above video
and all of my other 200+ guides and videos.
This is a one-time payment— no subscriptions or auto-renewals to worry about cancelling.
Your support helps me continue creating free, high-quality videos. Thank you!