Tibbles (Modern Data Frames)
A tibble is the tidyverse's modern reimagining of the data frame — a rectangular table that prints compactly, never silently changes your data's type, and never partial-matches a column name.
Learn Tibbles (Modern Data Frames) in our free R course — a beginner-friendly interactive lesson with worked examples, a practice exercise and a quick…
Part of the free R course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
In this lesson you'll build tibbles with tibble() , see how they differ from data.frame() , convert existing data with as_tibble() , and meet list columns — the feature that powers advanced tidyverse workflows.
What You'll Learn in This Lesson
1️⃣ Building a Tibble
You create a tibble with tibble() , passing one named argument per column. Each column is an ordinary vector, and all columns must be the same length (length-1 values are recycled). When you print it, a tibble shows the dimensions, the column names, and — crucially — the type of each column ( <chr> for character, <dbl> for double).
A neat bonus: tibble() evaluates its arguments in order, so you can build a column from columns defined earlier in the same call.
2️⃣ No Surprises: Types & Names
Two long-standing data-frame gotchas disappear with tibbles. First, tibbles never coerce a character column into a factor — what you type is what you get. (Old R turned strings into factors unless you set stringsAsFactors = FALSE ; this was the default until R 4.0.) Second, tibbles disable partial matching of column names, so a typo returns NULL with a warning instead of silently handing you the wrong column.
These guarantees matter most in scripts you run unattended: a silent factor conversion or a partial-match typo can corrupt an analysis without raising an error. Tibbles fail loudly so you catch problems early.
3️⃣ Converting & List Columns
You rarely have to start from scratch. as_tibble() upgrades any existing data frame, and because tibbles don't use row names, you can capture them into a real column with the rownames = argument.
The most distinctive tibble feature is the list column : a column whose cells each hold a list element — a vector, a data frame, even a model. Tibbles print these cleanly, which is why they underpin nested, "many models" workflows.
Your turn. Fill in the # TODO blank, run it, and confirm the column types print.
Mini-Challenge: tibble vs data.frame
Build the same dataset two ways and compare. This is the fastest way to feel the difference in printing, type handling, and strictness for yourself.
Common Errors (and the fix)
- ❌ could not find function "tibble" — ✅ run library(tibble) (or library(tidyverse) ) first; the package must be loaded.
- ❌ Columns of different lengths error — ✅ every column must be the same length, except length-1 values, which are recycled. Check with lengths() .
- ❌ A function complains it can't handle the tibble — ✅ a few older base functions expect row names; wrap with as.data.frame() .
- ❌ tib$nam returns NULL — ✅ that's the strict-name feature working. Spell the column name in full; tibbles don't partial-match.
Pro Tips
- 💡 See more rows: print(tib, n = 50) overrides the 10-row default; View(tib) opens the full table in RStudio.
- 💡 Row-by-row entry: tribble() lets you type a small tibble in a readable, spreadsheet-like layout.
- 💡 Glimpse instead of print: glimpse(tib) shows every column with its type and first few values — great for wide tables.
📋 Quick Reference — Tibbles
Task
R Syntax
Create a tibble
tibble(a = 1:3, b = c("x","y","z"))
Convert a data frame
as_tibble(df)
Keep row names
as_tibble(df, rownames = "id")
Back to data frame
as.data.frame(tib)
Print more rows
print(tib, n = 50)
Type-by-type summary
glimpse(tib)
Frequently Asked Questions
🎉 Lesson Complete!
- ✅ A tibble is a modern data frame from the tibble package
- ✅ tibble() prints column types and only the first 10 rows
- ✅ No silent factor conversion and no partial name matching
- ✅ as_tibble() upgrades a data frame; as.data.frame() goes back
- ✅ List columns let each cell hold a vector, frame, or model
- ✅ Next lesson: Reshaping with pivot_longer & pivot_wider
Practice quiz
What is a tibble?
- A base R matrix
- A named list only
- The tidyverse's modern data frame
- A plotting function
Answer: The tidyverse's modern data frame. A tibble is the tidyverse's enhanced data frame from the tibble package.
What class does a tibble have?
- Only "data.frame"
- Only "matrix"
- "list" alone
- c("tbl_df", "tbl", "data.frame")
Answer: c("tbl_df", "tbl", "data.frame"). A tibble IS a data frame with extra classes layered on top.
How many rows does a tibble print by default?
- The first 10
- All of them
- Just 1
- 100
Answer: The first 10. A tibble prints only the first 10 rows plus a summary, to avoid flooding the console.
What does a tibble show under each column name when printed?
- The row count
- The column type, e.g. <chr> or <dbl>
- Nothing
- The mean
Answer: The column type, e.g. <chr> or <dbl>. Tibbles print the type tag (<chr>, <dbl>) beneath each column name.
How do tibbles handle character columns compared to old data.frame()?
- They drop them
- They sort them
- They never coerce them to factors
- They convert them to numbers
Answer: They never coerce them to factors. Tibbles keep characters as characters; no silent factor conversion.
What happens with partial column-name matching on a tibble (e.g. tib$gr for 'grade')?
- It returns 'grade'
- It errors fatally
- It renames the column
- It returns NULL with a warning (no partial match)
Answer: It returns NULL with a warning (no partial match). Tibbles disable partial matching, so a typo returns NULL with a warning.
Which function converts an existing data frame into a tibble?
- as_tibble()
- make.tibble()
- tibble.cast()
- to_tbl()
Answer: as_tibble(). as_tibble() upgrades a data frame (or matrix) to a tibble.
How do you convert a tibble back to a plain data frame?
- unframe()
- as.data.frame()
- untibble()
- base()
Answer: as.data.frame(). as.data.frame() turns a tibble back into a base data frame.
What is a list column in a tibble?
- A column of column names
- A factor column
- A column of NA values
- A column whose cells each hold a list element (vector, frame, or model)
Answer: A column whose cells each hold a list element (vector, frame, or model). List columns store one list element per row, powering nested workflows.
Can you reference a column you just defined within the same tibble() call?
- Yes — tibble() evaluates arguments in order
- No, never
- Only with data.frame()
- Only for numeric columns
Answer: Yes — tibble() evaluates arguments in order. tibble() lets later columns use earlier ones; base data.frame() cannot.
Continue this course
- Previous: Checkpoint: R Basics
- Next: Reshaping: pivot_longer & pivot_wider