forked from rstudio-education/tidyverse-cookbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
166 lines (124 loc) · 6.18 KB
/
index.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
---
title: "The Tidyverse Cookbook"
author: "Edited by Garrett Grolemund"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
github-repo: rstudio-education/tidyverse-cookbook
documentclass: book
description: "How to solve common data science tasks with R's Tidyverse"
---
# Welcome {-}
<!--
```{block2, type = "rmdtip"}
This book is an R community project, and it wouldn't be nearly as good without your help. There are a number of ways you can contribute, from spotting typos to adding recipes. Read [How to Contribute] to get started.
```
-->
This book collects code recipes for doing data science with R's [tidyverse](#what-is-the-tidyverse). Each recipe solves a single common task, with a minimum of discussion. Everything in this book is licensed under the permissive [Creative Commons 4.0 International License](https://creativecommons.org/licenses/by/4.0/). We encourage you to reuse and adapt the recipes.
## Legal disclaimer {-}
I believe that each recipe in this book works as advertised, but be aware that the recipes come with the same warranty as R: ABSOLUTELY NO WARRANTY.
***
The online version of this book is licensed under the [Creative Commons 4.0 International License](https://creativecommons.org/licenses/by/4.0/).
<!--
# How to contribute {-}
Please help us improve this book. Here are some ways to join the fun:
1. **Proofread** - If something does not work, please
[let me know](https://github.com/rstudio-education/tidyverse-cookbook/issues). Your vigilence is valuable!
1. **Vote on which recipes to add next** - Visit the [github issue tracker](https://github.com/rstudio-education/tidyverse-cookbook/issues) and upvote the recipes that you would like someone to write.
1. **Suggest a recipe** - Propose new recipes on the [github issue tracker](https://github.com/rstudio-education/tidyverse-cookbook/issues). To propose a recipe, visit the [tracker](https://github.com/rstudio-education/tidyverse-cookbook/issues) and then:
1. Check that your recipe has not been proposed already. You'll know if it has because proposed recipes will appear in the list of open issues. If your recipe has already been requested, upvote it.
2. Click New Issue and then write and save your proposal. To help us write the recipe please:
* Make your request very specific. Each recipe should focus on one single, simple task. No homework problems please.
* Include the recipe template below. Don't forget to change the `TITLE` and to complete the "You want to" sentence. This template will be the beginning of the finished recipe.
```{r eval = FALSE}
## TITLE
You want to
#### Solution {-}
#### Discussion {-}
```
1. **Write a recipe or fix a typo** - If you would like to add a recipe, or if you spot a typo, feel free to edit the underlying page and send a pull request. If you've never done this before, the process is very easy:
1. Click the edit icon in the header at the top of this page.
2. Make the changes using github's in-page editor and save.
```{block2, type = "rmdcaution"}
If your changes add a recipe that has been proposed in the [github issue tracker](https://github.com/rstudio-education/tidyverse-cookbook/issues), add the phrase `Fixes #` and then the number of the issue that proposes the recipe. This will close the issue when your recipe is accepted.
```
3. Submit a pull request and include a brief description of your changes. "Fixing typos" is perfectly adequate.
```{block2, type = "rmdcaution"}
If you add a recipe or make significant changes, include this phrase in your pull request message: `CC BY 4.0.` This applies the [Creative Commons 4.0 International License](https://creativecommons.org/licenses/by/4.0/) to your contribution, which helps provide a uniform copyright for the entire book.
```
You can begin a recipe by copying and pasting the following template:
```{r eval = FALSE}
## TITLE
You want to
#### Solution {-}
#### Discussion {-}
```
Keep in mind that your solution code **must** run. When you write the recipe, assume that the user has run `library("tidyverse")` and nothing else. Where possible, try to minimize additional package dependencies.
A useful way to do this is to use data that comes in a tidyverse package. Here are the tidyverse data sets and the packages you'll find them in.
```{r eval = FALSE}
# data frames (tibbles)
dplyr::band_instruments
dplyr::band_instruments2
dplyr::band_members
dplyr::starwars
dplyr::storms
forcats::gss_cat
ggplot2::diamonds
ggplot2::economics
ggplot2::economics_long
ggplot2::faithfuld
ggplot2::midwest
ggplot2::mpg
ggplot2::msleep
ggplot2::presidential
ggplot2::seals
ggplot2::txhousing
modelr::heights
modelr::sim1
modelr::sim2
modelr::sim3
modelr::sim4
tidyr::population
tidyr::smiths
tidyr::table1
tidyr::table2
tidyr::table3
tidyr::table4a
tidyr::table4b
tidyr::table5
tidyr::who
# data frames (non-tibbles)
ggplot2::luv_colours
lubridate::lakers
# arrays
dplyr::nasa
# character vectors
stringr::fruit
stringr::sentences
stringr::words
```
Unfortunately, the tidyverse packages do not include example lists. I recommend that you use these lists, which come with base R.
```{r eval = FALSE}
# lists
ability.cov
Harman23.cor
Harman74.cor # long!
state.center
```
Alternatively, you can use these lists which come in the repurrrsive package (which must be installed separately. These lists are more interesting than the base R examples; but, unfortunately, most are quite long.
```{r eval = FALSE}
# lists
repurrrsive::gap_split
repurrrsive::gh_repos
repurrrsive::gh_users
repurrrsive::got_chars
repurrrsive::sw_films
repurrrsive::sw_people
repurrrsive::sw_planets
repurrrsive::sw_species
repurrrsive::sw_starships
repurrrsive::sw_vehicles
repurrrsive::wesanderson
# data frames with a list-column
repurrrsive::gap_nested
```
-->