10.3 Tibbles

The tibble package gives us tibbles, which are very nearly the same thing as a data frame. Indeed, the name “tibble” is supposed to remind us of a data “table.”

Consider the class of bcscr::m111survey:

## [1] "data.frame"

Yep, it’s a data frame. But we can convert it to a tibble, as follows:

## [1] "tbl_df"     "tbl"        "data.frame"

You can treat tibbles like data frames. For now the primary practical difference is manifest when you print a tibble to the Console:

## # A tibble: 71 x 12
##    height ideal_ht sleep fastest weight_feel love_first extra_life seat 
##     <dbl>    <dbl> <dbl>   <int> <fct>       <fct>      <fct>      <fct>
##  1   76         78   9.5     119 1_underwei… no         yes        1_fr…
##  2   74         76   7       110 2_about_ri… no         yes        2_mi…
##  3   64         NA   9        85 2_about_ri… no         no         2_mi…
##  4   62         65   7       100 1_underwei… no         no         1_fr…
##  5   72         72   8        95 1_underwei… no         yes        3_ba…
##  6   70.8       NA  10       100 3_overweig… no         no         1_fr…
##  7   70         72   4        85 2_about_ri… no         yes        1_fr…
##  8   79         76   6       160 2_about_ri… no         yes        3_ba…
##  9   59         61   7        90 2_about_ri… no         yes        3_ba…
## 10   67         67   7        90 3_overweig… no         no         2_mi…
## # … with 61 more rows, and 4 more variables: GPA <dbl>,
## #   enough_Sleep <fct>, sex <fct>, diff.ideal.act. <dbl>

The output is automatically truncated, and the number of columns printed is determined by the width of your screen. This is a great convenience when one is dealing with larger data sets.

Many larger data tables in packages will come to you as tibbles.