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    11  9.72
## 2    12     7  7.34
## 3    13    10  7.56
## 4    14     9 11.3 
## 5    15    10  9.69

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-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0