tibble::as_tibble()
   get_help() docs


Description

The as_tibble() function is part of the {tibble} package, which is part of the {tidyverse}.

We use the as_tibble() function to coerce a variable into being a tibble. Usually, we use this to coerce a data frame into a tibble to achieve improved printing and other tibble behaviors.

To use this function, you need to either first load the {tibble} library, or always use the function with tibble::as_tibble() notation.

# Load the library
library(tibble)
# Or, load the full tidyverse:
library(tidyverse)

# Or, use :: notation
tibble::as_tibble()

Conceptual Usage

as_tibble(variable to coerce into a tibble)

Examples


# Coerce the built-in data frame iris into a tibble
iris_tibble <- as_tibble(iris)

iris_tibble
## # A tibble: 150 × 5
##    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
##           <dbl>       <dbl>        <dbl>       <dbl> <fct>  
##  1          5.1         3.5          1.4         0.2 setosa 
##  2          4.9         3            1.4         0.2 setosa 
##  3          4.7         3.2          1.3         0.2 setosa 
##  4          4.6         3.1          1.5         0.2 setosa 
##  5          5           3.6          1.4         0.2 setosa 
##  6          5.4         3.9          1.7         0.4 setosa 
##  7          4.6         3.4          1.4         0.3 setosa 
##  8          5           3.4          1.5         0.2 setosa 
##  9          4.4         2.9          1.4         0.2 setosa 
## 10          4.9         3.1          1.5         0.1 setosa 
## # … with 140 more rows