Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Getting started with tibbles
Creating tibbles
5. Create a tibble by column
Subsetting
Summary

Instruction

Let's find out how to create a tibble from scratch. There are several ways we can do this.

Creating a tibble is similar to creating a new data frame. We just list the columns as vectors of the same length. Let's create a tibble for the fruits we have in our kitchen. It goes like this:

tibble(
  name = c("apple", "orange", "pear", "grapefruit"),
  quantity = c(3,5,6,2)
)

Exercise

Create a similar tibble with the vegetables in our fridge:

  • 5 carrots,
  • 2 cauliflowers, and
  • 3 tomatoes.

Make sure your columns are named following the fruit tibble example – name and quantity.

Stuck? Here's a hint!

Type:

tibble(
  name = c("carrot", "cauliflower", "tomato"),
  quantity = c(5,2,3)
)