• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

R/H25-Oct-2021-5,0262,865

build/H03-May-2022-

inst/doc/H25-Oct-2021-2,6601,707

man/H25-Oct-2021-1,6961,446

src/H25-Oct-2021-395318

tests/H26-Sep-2021-16,75613,755

vignettes/H03-May-2022-2,2271,703

DESCRIPTIONH A D07-Nov-20211.9 KiB5352

LICENSEH A D26-Sep-202142 32

MD5H A D07-Nov-202115.9 KiB257256

NAMESPACEH A D25-Oct-20212.6 KiB112110

NEWS.mdH A D25-Oct-202138.4 KiB855508

README.mdH A D25-Oct-20218.6 KiB9362

README.md

1<!-- README.md is generated from README.Rmd. Please edit that file -->
2
3# tibble <img src="man/figures/logo.png" align="right" />
4
5<!-- badges: start -->
6
7[![R-CMD-check](https://github.com/tidyverse/tibble/workflows/R-CMD-check/badge.svg)](https://github.com/tidyverse/tibble/actions) [![codecov](https://app.codecov.io/gh/tidyverse/tibble/branch/master/graph/badge.svg)](https://app.codecov.io/gh/tidyverse/tibble) [![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/tibble)](https://cran.r-project.org/package=tibble) [![Life cycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)
8
9<!-- badges: end -->
10
11## Overview
12
13A **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()`](https://rdrr.io/r/base/print.html) method which makes them easier to use with large datasets containing complex objects.
14
15If you are new to tibbles, the best place to start is the [tibbles chapter](https://r4ds.had.co.nz/tibbles.html) in *R for data science*.
16
17## Installation
18
19<pre class='chroma'>
20<span class='c'># The easiest way to get tibble is to install the whole tidyverse:</span>
21<span class='nf'><a href='https://rdrr.io/r/utils/install.packages.html'>install.packages</a></span><span class='o'>(</span><span class='s'>"tidyverse"</span><span class='o'>)</span>
22
23<span class='c'># Alternatively, install just tibble:</span>
24<span class='nf'><a href='https://rdrr.io/r/utils/install.packages.html'>install.packages</a></span><span class='o'>(</span><span class='s'>"tibble"</span><span class='o'>)</span>
25
26<span class='c'># Or the the development version from GitHub:</span>
27<span class='c'># install.packages("devtools")</span>
28<span class='nf'>devtools</span><span class='nf'>::</span><span class='nf'><a href='https://devtools.r-lib.org//reference/remote-reexports.html'>install_github</a></span><span class='o'>(</span><span class='s'>"tidyverse/tibble"</span><span class='o'>)</span></pre>
29
30## Usage
31
32<pre class='chroma'>
33<span class='kr'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='o'>(</span><span class='nv'><a href='https://tibble.tidyverse.org/'>tibble</a></span><span class='o'>)</span></pre>
34
35Create a tibble from an existing object with [`as_tibble()`](https://tibble.tidyverse.org/reference/as_tibble.html):
36
37<pre class='chroma'>
38<span class='nv'>data</span> <span class='o'>&lt;-</span> <span class='nf'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span><span class='o'>(</span>a <span class='o'>=</span> <span class='m'>1</span><span class='o'>:</span><span class='m'>3</span>, b <span class='o'>=</span> <span class='nv'>letters</span><span class='o'>[</span><span class='m'>1</span><span class='o'>:</span><span class='m'>3</span><span class='o'>]</span>, c <span class='o'>=</span> <span class='nf'><a href='https://rdrr.io/r/base/Sys.time.html'>Sys.Date</a></span><span class='o'>(</span><span class='o'>)</span> <span class='o'>-</span> <span class='m'>1</span><span class='o'>:</span><span class='m'>3</span><span class='o'>)</span>
39<span class='nv'>data</span>
40<span class='c'>#&gt;   a b          c</span>
41<span class='c'>#&gt; 1 1 a 2021-07-31</span>
42<span class='c'>#&gt; 2 2 b 2021-07-30</span>
43<span class='c'>#&gt; 3 3 c 2021-07-29</span>
44
45<span class='nf'><a href='https://tibble.tidyverse.org/reference/as_tibble.html'>as_tibble</a></span><span class='o'>(</span><span class='nv'>data</span><span class='o'>)</span>
46<span class='c'>#&gt; <span style='color: #555555;'># A tibble: 3 × 3</span></span>
47<span class='c'>#&gt;       <span style='font-weight: bold;'>a</span> <span style='font-weight: bold;'>b</span>     <span style='font-weight: bold;'>c</span>         </span>
48<span class='c'>#&gt;   <span style='color: #555555; font-style: italic;'>&lt;int&gt;</span> <span style='color: #555555; font-style: italic;'>&lt;chr&gt;</span> <span style='color: #555555; font-style: italic;'>&lt;date&gt;</span>    </span>
49<span class='c'>#&gt; <span style='color: #555555;'>1</span>     1 a     2021-07-31</span>
50<span class='c'>#&gt; <span style='color: #555555;'>2</span>     2 b     2021-07-30</span>
51<span class='c'>#&gt; <span style='color: #555555;'>3</span>     3 c     2021-07-29</span></pre>
52
53This will work for reasonable inputs that are already data.frames, lists, matrices, or tables.
54
55You can also create a new tibble from column vectors with [`tibble()`](https://tibble.tidyverse.org/reference/tibble.html):
56
57<pre class='chroma'>
58<span class='nf'><a href='https://tibble.tidyverse.org/reference/tibble.html'>tibble</a></span><span class='o'>(</span>x <span class='o'>=</span> <span class='m'>1</span><span class='o'>:</span><span class='m'>5</span>, y <span class='o'>=</span> <span class='m'>1</span>, z <span class='o'>=</span> <span class='nv'>x</span> <span class='o'>^</span> <span class='m'>2</span> <span class='o'>+</span> <span class='nv'>y</span><span class='o'>)</span>
59<span class='c'>#&gt; <span style='color: #555555;'># A tibble: 5 × 3</span></span>
60<span class='c'>#&gt;       <span style='font-weight: bold;'>x</span>     <span style='font-weight: bold;'>y</span>     <span style='font-weight: bold;'>z</span></span>
61<span class='c'>#&gt;   <span style='color: #555555; font-style: italic;'>&lt;int&gt;</span> <span style='color: #555555; font-style: italic;'>&lt;dbl&gt;</span> <span style='color: #555555; font-style: italic;'>&lt;dbl&gt;</span></span>
62<span class='c'>#&gt; <span style='color: #555555;'>1</span>     1     1     2</span>
63<span class='c'>#&gt; <span style='color: #555555;'>2</span>     2     1     5</span>
64<span class='c'>#&gt; <span style='color: #555555;'>3</span>     3     1    10</span>
65<span class='c'>#&gt; <span style='color: #555555;'>4</span>     4     1    17</span>
66<span class='c'>#&gt; <span style='color: #555555;'>5</span>     5     1    26</span></pre>
67
68[`tibble()`](https://tibble.tidyverse.org/reference/tibble.html) does much less than [`data.frame()`](https://rdrr.io/r/base/data.frame.html): 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()`](https://rdrr.io/r/base/row.names.html). You can read more about these features in [`vignette("tibble")`](https://tibble.tidyverse.org/articles/tibble.html).
69
70You can define a tibble row-by-row with [`tribble()`](https://tibble.tidyverse.org/reference/tribble.html):
71
72<pre class='chroma'>
73<span class='nf'><a href='https://tibble.tidyverse.org/reference/tribble.html'>tribble</a></span><span class='o'>(</span>
74  <span class='o'>~</span><span class='nv'>x</span>, <span class='o'>~</span><span class='nv'>y</span>,  <span class='o'>~</span><span class='nv'>z</span>,
75  <span class='s'>"a"</span>, <span class='m'>2</span>,  <span class='m'>3.6</span>,
76  <span class='s'>"b"</span>, <span class='m'>1</span>,  <span class='m'>8.5</span>
77<span class='o'>)</span>
78<span class='c'>#&gt; <span style='color: #555555;'># A tibble: 2 × 3</span></span>
79<span class='c'>#&gt;   <span style='font-weight: bold;'>x</span>         <span style='font-weight: bold;'>y</span>     <span style='font-weight: bold;'>z</span></span>
80<span class='c'>#&gt;   <span style='color: #555555; font-style: italic;'>&lt;chr&gt;</span> <span style='color: #555555; font-style: italic;'>&lt;dbl&gt;</span> <span style='color: #555555; font-style: italic;'>&lt;dbl&gt;</span></span>
81<span class='c'>#&gt; <span style='color: #555555;'>1</span> a         2   3.6</span>
82<span class='c'>#&gt; <span style='color: #555555;'>2</span> b         1   8.5</span></pre>
83
84## Related work
85
86The tibble print method draws inspiration from [data.table](https://rdatatable.gitlab.io/data.table), and [frame](https://github.com/patperry/r-frame). Like [`data.table::data.table()`](https://Rdatatable.gitlab.io/data.table/reference/data.table.html), [`tibble()`](https://tibble.tidyverse.org/reference/tibble.html) doesn’t coerce strings to factors by default, doesn’t change column names, and doesn’t use rownames.
87
88------------------------------------------------------------------------
89
90## Code of Conduct
91
92Please note that the tibble project is released with a [Contributor Code of Conduct](https://tibble.tidyverse.org/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
93