## 5.1 Introduction

Tibbles are not new to us. In Section 1.5, we learned that tables of data come in different types (e.g., matrices, data frames, and tibbles). Since then, we have been using mostly tibbles without reflecting on them. For instance, in Chapter 3 on Transforming data we used tibbles as the inputs of dplyr commands (e.g., arrange, filter, select, mutate, group_by, and summarise), which then returned modified tibbles as their outputs. Similary, the chapters on Visualizing data (Chapter 2) and EDA (Chapter 4) used tibbles as an input to ggplot() commands.

This chapter will explicate some features of tibbles that we may not have noticed before and introduce functions of the tibble package (Müller & Wickham, 2019), which provides additional ways of creating the fundamental data structure of the tidyverse.

### 5.1.1 Objectives

After working through this chapter, you should be able to use tibble commands to:

1. turn rectangular data into a tibble;
2. turn vectors of variables into (the columns of) a tibble;
3. turn cases into (the rows of) a tibble;
4. enter some data into a tibble; and
5. understand some limitations of rectangular data.

### 5.1.2 Data used

In this chapter, we will mostly use data provided by the datasets package that comes with R. In contrast to data included in the tidyverse, these datasets typically are not stored as tibbles, but can easily be converted into them. In addition to creating tibbles out of other data, we will also learn to create new tibbles from scratch.

This chapter formerly assumed that you have read and worked through Chapter 10: Tibbles of the r4ds textbook (Wickham & Grolemund, 2017). It now can be read by itself, but reading Chapter 10 of r4ds is still recommended.

Please do the following to get started:

• Create an R Markdown (.Rmd) document (for instructions, see Appendix E and the templates linked in Section E.2).

• Structure your document by inserting headings and empty lines between different parts. Here’s an example how your initial file could look:

---
title: "Chapter 5: Tibbles"
date: "2020 February 10"
output: html_document
---

Add text or code chunks here.

# Exercises (05: Tibbles)

## Exercise 1

## Exercise 2

etc.

<!-- The end (eof). -->
• Create an initial code chunk below the header of your .Rmd file that loads the R packages of the tidyverse (and see Section E.3.3 if you want to get rid of the messages and warnings of this chunk in your HTML output).

• Save your file (e.g., as 05_tibbles.Rmd in the R folder of your current project) and remember saving and knitting it regularly as you keep adding content to it.

### References

Müller, K., & Wickham, H. (2019). tibble: Simple data frames. Retrieved from https://CRAN.R-project.org/package=tibble

Wickham, H., & Grolemund, G. (2017). R for data science: Import, tidy, transform, visualize, and model data. Retrieved from http://r4ds.had.co.nz