3.2 A Tibble as a Dataset

20220527 A tibble is a New Zealander’s pronunciation of table. It is an improved representation of a data frame.

A tibble can be created column-wise with named parameters to tidyr::tibble().

tibble(a=11:15, b=rbinom(5, 150, 0.05), c=rnorm(5, 10, 1))
## # A tibble: 5 × 3
##       a     b     c
##   <int> <int> <dbl>
## 1    11     9 11.0 
## 2    12    10  9.19
## 3    13     7 10.3 
## 4    14     9  9.84
## 5    15     1 11.9

An alternative and more readable form of the call to tidyr::tibble() can be used.

tibble::tribble(
  ~date,      ~item,       ~amount,
  "Jun 2019", "fixed",     99,
  "Jun 2019", "consumed",  170,
  "Jun 2019", "generated", 313,
  "Sep 2019", "fixed",     97,
  "Sep 2019", "consumed",  251,
  "Sep 2019", "generated", 329)
## # A tibble: 6 × 3
##   date     item      amount
##   <chr>    <chr>      <dbl>
## 1 Jun 2019 fixed         99
## 2 Jun 2019 consumed     170
## 3 Jun 2019 generated    313
## 4 Sep 2019 fixed         97
## 5 Sep 2019 consumed     251
## 6 Sep 2019 generated    329


Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0