forked from tidyverse/tibble
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
71 lines (51 loc) · 2.58 KB
/
Copy pathREADME.Rmd
File metadata and controls
71 lines (51 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
output:
github_document:
html_preview: false
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# tibble <img src="man/figures/logo.png" align="right" />
[](https://travis-ci.org/tidyverse/tibble)
[](https://ci.appveyor.com/project/tidyverse/tibble)
[](https://codecov.io/gh/tidyverse/tibble)
[](https://cran.r-project.org/package=tibble)
## 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](http://r4ds.had.co.nz/tibbles.html) in R for data science.
## Installation
```{r, eval = FALSE}
# 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()`:
```{r}
library(tibble)
as_tibble(iris)
```
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()`:
```{r}
tibble(x = 1:5, y = 1, z = x ^ 2 + y)
```
`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()`:
```{r}
tribble(
~x, ~y, ~z,
"a", 2, 3.6,
"b", 1, 8.5
)
```