Class Meeting 26 (12) Introduction to creating packages in R

This lecture is 100% complete

26.1 Today’s Agenda

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 runningcreate_package, in the new RStudio session, you will need to again run library('devtools')

  • Section 2.7: running use_r("fbind") will automatically put fbind.R in the directory foofactors/R/

  • Section 2.8: load_all() should be run in the R console

  • Section 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):

  1. Remind yourself of our TAs (Andrea, Matthew, Sirine, and Yulia)

  2. 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.

  3. If you want to evaluate more than one TA, fill out the form again.

  4. 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!