Skip to content

Session 1 guide

Selin Jessa edited this page May 4, 2020 · 13 revisions

Code working group - Session 1

Agenda

  • 9:05-9:10: Plan for the next few weeks (Selin)
  • 9:10-9:20: Git basics and repository organization / workflow (Nic)
  • 9:20-9:30: Sandbox package intro (Selin)
    • Structure
    • Functions
    • Function documentation
  • 9:30-9:35: Task explanation (Selin)
  • 9:35-9:50: Task demo, or Git basics demo, (Nic)
  • Questions

Links

Task

In this task, we'll set up the sandbox repository locally on our own machines, and then add a basic function

Outcomes:

  • Understand Git workflow basics
  • Understand package structure & function documentation

Steps:

(The 🌟 marks steps that are great habits to use in your regular day-to-day coding)

  1. Set up your local env for development
    • Git and ssh keys
    • roxygen2 R package
  2. Create an issue on GitHub
  3. Clone the sandbox repository to your machine
  4. Switch to the develop-private branch
  5. Create a new branch, corresponding to your issue
  6. Add your function in a new .R file in the R/ directory
  7. Document your function: 🌟
    • If using roxygen2 in RStudio, with your cursor inside the function, add the documentation skeleton by going to "Code > Insert Roxygen Skeleton"
    • Otherwise, type out the template
    • Populate the "Title", @param, @return, and @examples fields (as a rule of thumb, @param and @return should tell you what type of object is received/returned - numeric, character vector, list with named slots, etc - and what it should/will contain)
  8. Build documentation
    • In RStudio: Rebuild documentation by going to "Build > Document" (if you use the shortcut Cmd + shift + D, it's rebuilding the documentation)
    • From the R command line: Rebuild documentation with roxygen2::roxygenise()
    • At this point, you should see an .Rd file created under man for your function
  9. Add & commit your changes with a descriptive message, in the imperative tense
  10. Push the commits on your branch to the remote (GitHub) - you will need to create the new branch

What kind of function to add:

  1. Takes a numeric parameter
  2. Manipulation of the fibonacci vector, using the parameter
  3. Returns a numeric output

Examples:

  • Raise the vector to the nth power
  • Create a new vector which recycles fibonacci n times
  • Return the nth element

Resources:

Helpful resources for R package development

Helpful Git basics resources (notes from Nic)

Helpful Git workflow resources (notes from Nic)