forked from TheDataMine/the-examples-book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
217 lines (149 loc) · 10.6 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
---
title: "The Examples Book"
site: "bookdown::bookdown_site"
documentclass: book
bibliography: [book.bib, packages.bib]
biblio-style: apalike
link-citations: yes
# url: 'https\://datamine.purdue.edu/examples/'
# cover-image: "images/cover.png"
github-repo: kevinamstutz/the-examples-book
apple-touch-icon: "images/touch-icon.png"
favicon: "images/favicon.ico"
description: "A book of supplemental examples for The Data Mine at Purdue University."
output:
bookdown::pdf_book:
number_sections: no
includes:
in_header: "box.tex"
bookdown::epub_book:
number_sections: no
bookdown::gitbook:
number_sections: no
md_extensions: +raw_html
knit: (function(inputFile, encoding) {
bookdown::render_book(inputFile, encoding = encoding,
output_dir = "docs", output_format = "all") })
---
<script type="application/json" class="js-hypothesis-config">
{"showHighlights": false}
</script>
<script src="https://hypothes.is/embed.js" async></script>
```{r, echo=F}
# This code chunk is not displayed. The purpose of this code chunk is to download and load
# the datasets used throughout the book a single time, in a single place. A list of
# the datasets names is in datasets.md in the root directory in the repo.
library(data.table)
transactions_5000 <- data.frame(fread("http://llc.stat.purdue.edu/5000_transactions.csv", nrows=1000000))
grades <- read.csv("grades.csv")
taxi_201906 <- data.frame(fread("http://llc.stat.purdue.edu/yellow_tripdata_2019-06.csv"))
flights_sample <- read.csv("flights_sample.csv")
```
# Introduction {#introduction}
<iframe id="kaltura_player" src="https://cdnapisec.kaltura.com/p/983291/sp/98329100/embedIframeJs/uiconf_id/29134031/partner_id/983291?iframeembed=true&playerId=kaltura_player&entry_id=1_i7x6tz4r&flashvars[streamerType]=auto&flashvars[localizationCode]=en&flashvars[leadWithHTML5]=true&flashvars[sideBarContainer.plugin]=true&flashvars[sideBarContainer.position]=left&flashvars[sideBarContainer.clickToClose]=true&flashvars[chapters.plugin]=true&flashvars[chapters.layout]=vertical&flashvars[chapters.thumbnailRotator]=false&flashvars[streamSelector.plugin]=true&flashvars[EmbedPlayer.SpinnerTarget]=videoHolder&flashvars[dualScreen.plugin]=true&flashvars[Kaltura.addCrossoriginToIframe]=true&&wid=1_5ixg4x2u" allowfullscreen webkitallowfullscreen mozAllowFullScreen allow="autoplay *; fullscreen *; encrypted-media *" sandbox="allow-forms allow-same-origin allow-scripts allow-top-navigation allow-pointer-lock allow-popups allow-modals allow-orientation-lock allow-popups-to-escape-sandbox allow-presentation allow-top-navigation-by-user-activation" frameborder="0" title="Kaltura Player"></iframe>
This book contains a collection of examples that students can use to reinforce topics learned in The Data Mine seminar. It is an excellent resource for students to learn what they need to know in order to solve The Data Mine projects.
## How to contribute {#how-to-contribute}
Contributing to this book is simple:
### Small changes and additions
If you have a small change or addition you'd like to make to the book, the easiest way to quickly contribute would be the following method.
1. Navigate to the page or section that needs to be edited
2. Click on the "Edit" button towards the upper left side of the page:
![](images/edit_button.png)
3. You'll be presented with the respective RMarkdown file. Make your modifications.
4. In the "Commit changes" box, select the radio button that says _Create a **new branch** for this commit and start a pull request._ Give your pull request a title and a detailed description. Name the new branch, and click on "Propose file change".
5. You've successfully submitted a pull request. Our team will review and merge the request shortly thereafter.
### Larger changes or additions
If you have larger changes or additions you'd like to make to the book, the easiest way is to edit the contents of the book on your local machine.
#### Using `git` in the terminal
1. Setup `git` following the directions [here](#git-install).
2. Start by opening up a terminal and [configuring `git` to work with GitHub](#configure-git).
3. Navigate to the directory in which you would like to clone the-examples-book repository. For example, if I wanted to clone the repository in my `~/projects` folder, I'd first execute: `cd ~/projects`.
4. [Clone the repository](#git-clone-repository). In this example, let's assume I've cloned the repository into my `~/projects` folder.
5. Navigate into the project folder:
```bash
cd ~/projects/the-examples-book
```
6. At this point in time your current branch should be the `master` branch. You can verify by running:
```bash
git branch
```
**Note:** The highlighted branch starting with "*" is the current branch.
or if you'd like just the name of the branch:
```bash
git rev-parse --abbrev-ref HEAD
```
7. [Create a new branch](#git-create-new-branch) with whatever name you'd like, and check that branch out. For example, `fix-spelling-errors-01`.
8. Open up RStudio. In the "Files" tab in RStudio, navigate to the repository. In this example, we would navigate to `/Users/kamstut/Documents/GitHub/the-examples-book`. Click on the "More" dropdown and select "Set As Working Directory".
9. If you do not already have `renv` installed, install it by running the following commands in the console:
```r
install.packages("renv")
```
10. Restore the environment by running the following commands in the console:
```r
renv::restore()
```
11. In order to compile this book, you must have LaTeX installed. The easiest way to accomplish this is to run the following in the R console:
```r
install.packages("tinytex")
library(tinytex)
tinytex::install_tinytex()
```
12. In addition, make sure to install both `pandoc` and `pandoc-citeproc` by following the instructions [here](https://pandoc.org/installing.html).
13. Modify the `.Rmd` files to your liking.
14. Click the "Knit" button to compile the book. The resulting "book" is within the "docs" folder.
**Important note:** If at any point in time you receive an error saying something similar to "there is no package called `my_package`, simply install the missing package, and try to knit again:
```r
install.packages("my_package")
library(my_package)
```
15. To test the book out, navigate to the "docs" folder and open the `index.html` in the browser of your choice.
16. When you are happy with the modifications you've made, [commit your changes](#git-commit-changes) to the repository.
17. You can continue to make modifications and commit your changes locally. When you are ready, you can [push your branch](#git-push-local-commits) to the remote repository (github.com).
18. At this point in time, you can confirm that the branch has been succesfully pushed to github.com by navigating to the repository on github, and click on the "branches" tab:
![](./images/gh-desktop-14.png)
19. Next, [create a pull request](). Note that a "Pull Request" is a GitHub-specific concept. You cannot create a pull request using `git`. Navigate to the repository https://github.com/thedatamine/the-examples-book, and you should see a message asking if you'd like to create a pull request:
![](./images/pr-01.png)
20. Leave a detailed comment about what you've modified or added to the book. You can click on "Preview" to see what your comment will look like. [GitHub's markdown](https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax) applies here. Once satisfied, click "Create pull request".
21. At this point in time, the repository owners will receive a notification and will check and potentially merge the changes into the `master` branch.
#### Using GitHub Desktop
1. Setup GitHub Desktop following the directions [here](#github-desktop-install).
2. When you are presented with the following screen, select "Clone a Repository from the Internet...":
![](./images/gh-desktop-03.png)
3. Click on the "URL" tab:
![](./images/gh-desktop-04.png)
4. In the first field, enter "TheDataMine/the-examples-book". This is the repository for this book.
5. In the second field, enter the location in which you'd like the repository to be cloned to. In this example, the repository will be cloned into `/Users/kamstut/Documents/GitHub`. The result will be a new folder called `the-examples-book` in `/Users/kamstut/Documents/GitHub`.
6. Click "Clone".
7. Upon completion, you will be presented with a screen similar to this:
![](./images/gh-desktop-05.png)
8. At this point in time, your current branch will be the `master` branch. [Create a new branch](#github-desktop-create-new-branch) with whatever name you'd like. For example, `fix-spelling-errors-01`.
9. Open up RStudio. In the "Files" tab in RStudio, navigate to the repository. In this example, we would navigate to `/Users/kamstut/Documents/GitHub/the-examples-book`. Click on the "More" dropdown and select "Set As Working Directory".
10. If you do not already have `renv` installed, install it by running the following commands in the console:
```r
install.packages("renv")
```
11. Restore the environment by running the following commands in the console:
```r
renv::restore()
```
12. In order to compile this book, you must have LaTeX installed. The easiest way to accomplish this is to run the following in the R console:
```r
install.packages("tinytex")
library(tinytex)
tinytex::install_tinytex()
```
13. In addition, make sure to install both `pandoc` and `pandoc-citeproc` by following the instructions [here](https://pandoc.org/installing.html).
14. Modify the `.Rmd` files to your liking.
15. Click the "Knit" button to compile the book. The resulting "book" is within the "docs" folder.
**Important note:** If at any point in time you receive an error saying something similar to "there is no package called `my_package`, simply install the missing package, and try to knit again:
```r
install.packages("my_package")
library(my_package)
```
16. To test the book out, navigate to the "docs" folder and open the `index.html` in the browser of your choice.
17. When you are happy with the modifications you've made, [commit your changes](#github-desktop-commit-changes) to the repository.
18. You can continue to make modifications and commit your changes locally. When you are ready, you can [publish your branch](#github-desktop-publish-branch):
![](./images/gh-desktop-13.png)
19. Upon publishing your branch, within GitHub Desktop, you'll be presented with the option to [create a pull request](#github-desktop-pull-request):
![](./images/gh-desktop-12.png)
20. At this point in time, the repository owners will receive a notification and will check and potentially merge the changes into the `master` branch.