Provides a 'tbl_df' class (the 'tibble') that provides stricter checking and better formatting than the traditional data frame.

Details

The S3 class tbl_df wraps a local data frame. The main advantage to using a tbl_df over a regular data frame is the printing: tbl objects only print a few rows and all the columns that fit on one screen, describing the rest of it as text.

Methods

tbl_df implements four important base methods:

print

By default only prints the first 10 rows (at most 20), and the columns that fit on screen; see print.tbl()

[

Does not simplify (drop) by default, returns a data frame

[[, $

Calls .subset2() directly, so is considerably faster. Returns NULL if column does not exist, $ warns.

Important functions

tibble() and tribble() for construction, as_tibble() for coercion, and print.tbl() and glimpse() for display.

See also

Useful links:

Examples

tibble(a = 1:26, b = letters)
#> # A tibble: 26 x 2 #> a b #> <int> <chr> #> 1 1 a #> 2 2 b #> 3 3 c #> 4 4 d #> 5 5 e #> 6 6 f #> 7 7 g #> 8 8 h #> 9 9 i #> 10 10 j #> # ... with 16 more rows
as_tibble(iris)
#> # A tibble: 150 x 5 #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> <dbl> <dbl> <dbl> <dbl> <fct> #> 1 5.10 3.50 1.40 0.200 setosa #> 2 4.90 3.00 1.40 0.200 setosa #> 3 4.70 3.20 1.30 0.200 setosa #> 4 4.60 3.10 1.50 0.200 setosa #> 5 5.00 3.60 1.40 0.200 setosa #> 6 5.40 3.90 1.70 0.400 setosa #> 7 4.60 3.40 1.40 0.300 setosa #> 8 5.00 3.40 1.50 0.200 setosa #> 9 4.40 2.90 1.40 0.200 setosa #> 10 4.90 3.10 1.50 0.100 setosa #> # ... with 140 more rows