A modern re-imagining of the data frame
HTML CSS R C JavaScript
Clone or download
Permalink
Failed to load latest commit information.
.github Revise CODEOWNERS to stop auto-request Jul 2, 2018
R - Subsetting one row retains columns for a matrix column. Jul 14, 2018
docs-dev Move development documentation away from website May 26, 2018
docs Move development documentation away from website May 26, 2018
man Document Jul 2, 2018
revdep update revdep results Jan 21, 2018
src character subsetting, closes #312 Oct 4, 2017
tests - Subsetting one row retains columns for a matrix column. Jul 14, 2018
vignettes - Fix consistency problems in intro vignette (#414), add colored output. May 25, 2018
.Rbuildignore Move development documentation away from website May 26, 2018
.deploy_key.enc set up deploy keys in travis Nov 11, 2016
.deploy_key.pub set up deploy keys in travis Nov 11, 2016
.gitattributes use merge=union for NAMESPACE Aug 16, 2016
.gitignore `tribble` now handles columns with a class Apr 20, 2017
.travis.yml Test R 3.3 and 3.4 Jul 1, 2018
API remove view() for now Jan 21, 2018
DESCRIPTION fledge: Bump version to 1.4.2.9004 Jul 14, 2018
LICENSE up year Jan 11, 2017
NAMESPACE document May 23, 2018
NEWS.md fledge: Bump version to 1.4.2.9004 Jul 14, 2018
README.Rmd Use https for image May 25, 2018
README.md tweak index and documentation Jan 20, 2018
_pkgdown.yml Move development documentation away from website May 26, 2018
appveyor.yml fix AppVeyor Nov 22, 2017
cran-comments.md CRAN comments Jan 21, 2018
tibble.Rproj Update RStudio/Rcpp May 26, 2017
tic.R don't auto-build pkgdown for now Jan 4, 2018

README.md

tibble

Build Status AppVeyor Build Status codecov CRAN_Status_Badge

Overview

A tibble, or tbl_df, is a modern reimagining of the data.frame, keeping what time has proven to be effective, and throwing out what is not. Tibbles are data.frames that are lazy and surly: they do less (i.e. they don't change variable names or types, and don't do partial matching) and complain more (e.g. when a variable does not exist). This forces you to confront problems earlier, typically leading to cleaner, more expressive code. Tibbles also have an enhanced print() method which makes them easier to use with large datasets containing complex objects.

If you are new to tibbles, the best place to start is the tibbles chapter in R for data science.

Installation

# The easiest way to get tibble is to install the whole tidyverse:
install.packages("tidyverse")

# Alternatively, install just tibble:
install.packages("tibble")

# Or the the development version from GitHub:
# install.packages("devtools")
devtools::install_github("tidyverse/tibble")

Usage

Create a tibble from an existing object with as_tibble():

library(tibble)
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

This will work for reasonable inputs that are already data.frames, lists, matrices, or tables.

You can also create a new tibble from column vectors with tibble():

tibble(x = 1:5, y = 1, z = x ^ 2 + y)
#> # A tibble: 5 x 3
#>       x     y     z
#>   <int> <dbl> <dbl>
#> 1     1  1.00  2.00
#> 2     2  1.00  5.00
#> 3     3  1.00 10.0 
#> 4     4  1.00 17.0 
#> 5     5  1.00 26.0

tibble() does much less than data.frame(): it never changes the type of the inputs (e.g. it never converts strings to factors!), it never changes the names of variables, it only recycles inputs of length 1, and it never creates row.names(). You can read more about these features in the vignette, vignette("tibble").

You can define a tibble row-by-row with tribble():

tribble(
  ~x, ~y,  ~z,
  "a", 2,  3.6,
  "b", 1,  8.5
)
#> # A tibble: 2 x 3
#>   x         y     z
#>   <chr> <dbl> <dbl>
#> 1 a      2.00  3.60
#> 2 b      1.00  8.50