Creating Tibbles

tibble(___ = ___, 
       ___ = ___, 
       ...)
as_tibble(___)
View Interactive Version

The creation of tibbles works exactly the same as for data frames. We can use the tibble() function from the tibble package to create a new tabular object.

For example, a tibble containing data from four different people and three columns can be created like this:

Input
library(tibble)
tibble(
  id = c(1, 2, 3, 4),
  name = c("Louisa", "Jonathan", "Luigi", "Rachel"),
  female = c(TRUE, FALSE, FALSE, TRUE)
)
Output
# A tibble: 4 x 3
     id name     female
  <dbl> <chr>    <lgl> 
1     1 Louisa   TRUE  
2     2 Jonathan FALSE 
3     3 Luigi    FALSE 
4     4 Rachel   TRUE  
Create and convert tibbles