forked from r4ds/bookclub-rpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-introduction.Rmd
138 lines (98 loc) · 4.31 KB
/
01-introduction.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
# (PART) Getting started {-}
# Introduction
**Learning objectives:**
1. Explain the **book club format.**
2. Explain **what** an **R package** is.
3. Describe **why** we should **develop packages.**
4. Discuss the philosophy behind the use of the **`devtools` and `usethis` packages** in **package development.**
## What is an R package?
* R packages can be defined based on their utility:
* A means to bundle code, data, documentation, and tests that can easily be shared with others.
* A package opens up the use of several workflow packages/tools.
* R packages can be defined by their structure:
* Discussed throughout the book club
* At its core, packages are defined by the conventions of how files and directories are organized: `/R`; `DESCRIPTION` file; `/tests`; `/data`; etc.
* [Packaging Data Analytical Work Reproducibly Using R (and Friends)](https://peerj.com/preprints/3192/)
## Installing and using packages
* Packages are available via [Comprehensive R Archive Network (CRAN)](https://cran.r-project.org/index.html)
* Packages are also available via different public repos
- [GitHub is the most popular](https://github.com/).
### Installing packages
```{r 01-install-packages, eval=FALSE}
install.packages("x")
library("x")
# Getting help
package?x
help(package = "x")
```
## Why develop packages?
* Allows us to more easily share and use code amongst the team and other collaborators.
* Saves yourself and your team's time.
* Opens up the use of several tools to more efficiently write code.
* Defines a formal organizational structure of where to put things.
* Allows us to develop more robust, rigorous, reproducible analyses.
* Helps us write better code.
## Philosophy behind the tools of R Package development
* Anything that can be automated, should be automated.
* Use functions for package development, avoid doing it by hand.
- To do this, we need to learn the functions/workflow.
- Our thinking should be on what we want the package to do, not on how to organize a package.
- This is where the [`devtools`](https://devtools.r-lib.org/) and [`usethis`](https://usethis.r-lib.org/) package come into play.
- Tools to insulate us from the low-level details of how packages are built.
* `devtools` works nicely with RStudio, so that's the development environment we will use.
```{r 01-install-devtools-usethis, eval=FALSE}
install.packages(c("devtools", "usethis"))
```
## What if we need more detail?
* The official manual is [Writing R Extensions](https://cran.r-project.org/doc/manuals/R-exts.html).
- This document is exhaustive.
## What we won't learn
* Important topics not covered in the book
- Git and Github
- Compiled code
- Markdown and Rmarkdown
## A note
* Don't get overwhelmed
- Some stuff you may never use.
- Remember, an R package at it's core is just an `R` directory.
* You are not expected to know everything.
- We are all learning.
- None of us is as smart as all of us.
- It's okay to say "I don't know."
- We can stop at anytime to discuss.
## Meeting Videos
### Cohort 1
`r knitr::include_url("https://www.youtube.com/embed/FR6NsbkYhcw")`
### Cohort 2
`r knitr::include_url("https://www.youtube.com/embed/7YgH8qfyzFU")`
### Cohort 3
`r knitr::include_url("https://www.youtube.com/embed/QOmdmGMxl_Q")`
<details>
<summary> Meeting chat log </summary>
```
00:07:46 Rex: Brisbane, Australia
00:36:26 Collin Berke: On a scale from 1 - 5, how familiar are you with using git for version control?
00:36:51 Ryan Metcalf: 4
00:36:52 Brendan Lam: 2
00:36:52 Arun Chavan: 3
00:36:53 Larissa Shaughnessy: 2
00:36:54 Isabella Velásquez: 4
00:36:57 Rex Parsons: 3
00:37:19 Collin Berke: On a scale from 1 - 5, how familiar are you with using GitHub?
00:37:38 Rex Parsons: 4
00:37:38 Arun Chavan: 4
00:37:38 Isabella Velásquez: 5
00:37:39 Brendan Lam: 2
00:37:41 Larissa Shaughnessy: 3
00:38:14 Collin Berke: On a scale from 1 - 5, how valuable would it be to devote a week to introducing git and GitHub?
00:38:29 Brendan Lam: 3
00:38:31 Arun Chavan: 2
00:38:35 Larissa Shaughnessy: 4
00:38:35 Ryan Metcalf: 4
00:38:36 Rex Parsons: 4
00:38:48 Isabella Velásquez: I am comfortable with Git, but if it’s valuable for the group!
01:05:36 Rex Parsons: Thanks, Collin!
```
</details>
### Cohort 4
`r knitr::include_url("https://www.youtube.com/embed/BaGzNVLqfAE")`