Class Meeting 26 (12) Introduction to creating packages in R
This lecture is 100% complete
26.1 Today’s Agenda
- Announcements: (5 mins)
- Reminder! Participation repos are due on Saturday April 11th!
- The participation checklist file is here
- If you finish early, please submit early also so we can get started on marking!
- Assignment 6 is posted (I have added 24 hours extra since it was posted late)
- Reminder! Participation repos are due on Saturday April 11th!
- Part 1: Showcase of the best STAT 547 dashboards! (10 mins)
- Part 2: Packages in R (10 mins)
- Why make packages?
- Components of a package in R
- Releasing a package
- Part 3: Creating a package in R (45 mins)
- Part 4: Final debrief: what’s next? (5 mins)
- RShiny
- Tests! Unit Tests!
- Continuous integration
26.2 Part 1: Showcase of the best STAT 547 dashboards! (10 mins)
Demo on laptop
26.3 Part 2: Packages in R (10 mins)
26.3.1 Why make packages?
We will introduce packages by tallking through sections of Chapter 1 of the R-pkgs textbook.
26.3.2 Components of a package in R
Section 1.2 of the textbook discusses the major components of an R package
- R code and functions
- Package “metadata”
- Documentation
- Vignettes
- Tests
- Namespace
- External data (if applicable)
26.3.3 [OPTIONAL] Releasing a package
If you are interested in releasing a package on CRAN (the R package repository), I suggest Chapter 18 of the R-pkgs textbook.
26.4 Part 3: Creating a package from scratch (45 mins)
Here we will be going through Chapter 2 of R packages.
Additional explanatory notes for STAT 547 by Firas:
Section 2.4: after running
create_package
, in the new RStudio session, you will need to again runlibrary('devtools')
Section 2.7: running
use_r("fbind")
will automatically putfbind.R
in the directoryfoofactors/R/
Section 2.8:
load_all()
should be run in the R consoleSection 2.8.1: Commit
fbind()
to your repo using the following commands (in a Terminal):
git add . #adds all modified files to stage for commit
git commit -m "add fbind function" # commits the modified files with a commit message
- Once you’re finished, “zip” or compress the foofactors directory, and commit it to your participation repo for cm112.
26.5 Part 4: Final debrief: what’s next? (5 mins)
26.5.1 Final reminder about Instructor and TA evaluations
Even under the extraordinary circumstances this term, we want to give you an opportunity to provide feedback to your Teaching Assistants (TAs), and for your TAs to learn from you. To fill out evaluations for this course’s TA(s):
Remind yourself of our TAs (Andrea, Matthew, Sirine, and Yulia)
Visit this link, and fill out the form for each TA you’d like to evaluate. You’ll be asked for this course’s name and section, which is [STAT-547M section 201], and you’ll be asked for the TA’s name.
If you want to evaluate more than one TA, fill out the form again.
The TA evaluation form will be available from March 28th to April 13th.
Your responses are anonymous—no student-identifying information will be collected. Your TAs will not see any evaluations until after final course grades have been submitted. The Department Head will also have access to these evaluations.
Thank you for your feedback!