Our illustrated penguins have reached the tibble package! The photo backdrop is a snowy Antarctic wonderland featuring a Gentoo penguin with outstretched flippers

tibble: info



A tibble is much like the dataframe in base R,
but optimized for use in the Tidyverse.

R4DS book cover


R for Data Science: Ch 10 Tibbles

Package documentation: https://tibble.tidyverse.org

tibble: exercise

Let’s take a look at the differences!

# try each of these commands in the console and see if 
# you can spot the differences!

as_tibble(penguins)
as.data.frame(penguins)
as_tibble(penguins) |> head(4)
# A tibble: 4 × 8
  species island    bill_length_mm bill_depth_mm flipper_length_mm body_mass_g
  <fct>   <fct>              <dbl>         <dbl>             <int>       <int>
1 Adelie  Torgersen           39.1          18.7               181        3750
2 Adelie  Torgersen           39.5          17.4               186        3800
3 Adelie  Torgersen           40.3          18                 195        3250
4 Adelie  Torgersen           NA            NA                  NA          NA
# ℹ 2 more variables: sex <fct>, year <int>


as.data.frame(penguins) |> head(4)
  species    island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g
1  Adelie Torgersen           39.1          18.7               181        3750
2  Adelie Torgersen           39.5          17.4               186        3800
3  Adelie Torgersen           40.3          18.0               195        3250
4  Adelie Torgersen             NA            NA                NA          NA
     sex year
1   male 2007
2 female 2007
3 female 2007
4   <NA> 2007

What differences do you see?

You might see a tibble prints:

  • variable classes
  • only 10 rows
  • only as many columns as can fit on the screen
  • NAs are highlighted in console so they’re easy to spot (font highlighting and styling in tibble)

Not so much a concern in an R Markdown file, but noticeable in the console

This enhanced print method makes it easier to work with large datasets

There are a couple of other main differences, namely in subsetting and recycling

Check them out in vignette("tibble")

vignette("tibble")