5.3 Creating tables with tibble

What can we do when our data cannot be read in as a rectangular table? And how can we create tibbles from other rectangular data structures (e.g., data frames)?

Tibbles are simple data tables and the primary way of representing data (in rows of cases and columns of variables) in the tidyverse (Wickham, 2019b). Internally, tibbles are a special, simplified form of a data frame.

Resources for this section include:

Key concepts of this section include:

  • rectangular data (with rows/cases and columns/variables)

  • tibbles vs. data frames

Key tibble functions include:

  • as_tibble() converts (or coerces) an existing rectangle of data (e.g., a data frame or matrix) into a tibble.

  • tibble() converts several vectors into (the columns of) a tibble.

  • tribble() converts a table (entered row-by-row) into a tibble.

Thus, the three functions differ by the types of inputs they expect, but have in common that they create a tibble as their output.

While some R veterans may prefer data frames, tibbles are becoming increasingly popular. But if we ever need to transform a tibble tb into a data frame, we can always use as.data.frame(tb).


Müller, K., & Wickham, H. (2021). tibble: Simple data frames. https://CRAN.R-project.org/package=tibble
Neth, H. (2021a). Data science for psychologists. Social Psychology; Decision Sciences, University of Konstanz. https://bookdown.org/hneth/ds4psy/
Wickham, H. (2019b). tidyverse: Easily install and load the ’tidyverse’. https://CRAN.R-project.org/package=tidyverse