-
Notifications
You must be signed in to change notification settings - Fork 7
/
02-tibble.Rmd
111 lines (84 loc) · 2.5 KB
/
02-tibble.Rmd
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
---
title: "02-tibble"
author: "Silvia P. Canelón"
date: "9/19/2020"
output: html_document
---
class: penguin-tour
```{r, echo=FALSE, out.width=1200}
knitr::include_graphics("images/pptx/02-tibble.png")
```
.footnote[
<span>Photo by <a href="https://unsplash.com/@eadesstudio?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">James Eades</a> on <a href="https://unsplash.com/collections/12240655/palmerpenguins/d5aed8c855e26061e5e651d3f180b76d?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a></span>
]
---
background-image: url(images/hex/tibble.png)
background-position: 1050px 50px
background-size: 80px
# tibble: info
.panelset[
.panel[.panel-name[Overview]
.pull-left[
### A `tibble` is much like the `dataframe` in base R, but optimized for use in the Tidyverse.
]
]
.panel[.panel-name[Cheatsheet]
`r icon::fa("file-pdf")` PDF (tidyr): https://github.com/rstudio/cheatsheets/raw/master/data-transformation.pdf
![](https://raw.githubusercontent.com/rstudio/cheatsheets/master/pngs/thumbnails/data-import-cheatsheet-thumbs.png)
]
.panel[.panel-name[Reading]
.left-column[
```{r echo=FALSE}
knitr::include_graphics("images/r4ds-cover.png")
```
]
.right-column[
### R for Data Science: [Ch 10 Tibbles](https://r4ds.had.co.nz/tibbles.html)
### Package documentation: https://tibble.tidyverse.org/
]
]
]
---
background-image: url(images/hex/tibble.png)
background-position: 1050px 50px
background-size: 80px
# tibble: exercise
.panelset[
.panel[.panel-name[Code]
Let's take a look at the differences!
```{r eval=FALSE}
# try each of these commands in the console and see if you can spot the differences!
as_tibble(penguins)
as.data.frame(penguins)
```
]
.panel[.panel-name[Result]
.pull-left[
```{r}
as_tibble(penguins)
```
]
.pull-right[
```{r}
as.data.frame(penguins)
```
]
]
.panel[.panel-name[Chat]
### What differences do you see?
You might see a `tibble` prints:
- variable classes
- only 10 rows
- only as many columns as can fit on the screen
- `NA`s are highlighted in console so they're easy to spot (font highlighting and styling in `tibble`)
Not so much a concern in an R Markdown file, but noticeable in the console.
Print method makes it easier to work with large datasets.
]
.panel[.panel-name[More]
There are a couple of other main differences, namely in **subsetting** and **recycling**. Check them out in the [`vignette("tibble")`](https://tibble.tidyverse.org/articles/tibble.html)
Try it out here!
```{r eval=FALSE}
vignette("tibble")
```
]
]