Tibble (R)

A tibble is the tidyverse's modern reimagining of the data frame. It behaves like a data frame but prints more cleanly, never silently changes types, and never converts strings to factors.

R

Provided by the tibble package (part of the tidyverse), a tibble is a data frame with friendlier defaults. It prints only the first 10 rows with column types shown, so a large dataset doesn't flood your console; it never coerces strings to factors; and it doesn't do partial column-name matching, which removes a common source of silent bugs.

Create one with tibble() or convert an existing data frame with as_tibble(). Because a tibble is still a data frame, it works everywhere a data frame is expected, and it's the structure dplyr verbs (filter, mutate, summarise) and ggplot2 expect to receive.

Subsetting a tibble with single brackets always returns a tibble (never silently drops to a vector), which makes pipelines more predictable. Choose a tibble over a base data.frame in modern tidyverse workflows.

Syntax

library(tibble)
tb <- tibble(x = 1:3, y = c("a", "b", "c"))

Examples

R — A tibble works like a data frame; tb$score is a numeric vector.

library(tibble)
tb <- tibble(
  name = c("Ana", "Sam"),
  score = c(90, 85)
)
print(mean(tb$score))

See also

Back to the Dictionary