Doing a weekly exercise
The same five steps, every week
That is the whole workflow. Everything below is detail.
Paste this line every time you open a project or restart R:
source("https://gph-2182.github.io/gph2182.R")You will know it worked when gph_start, gph_check and the rest appear under Functions in the Environment pane, top right.
If you forget, the first command you try fails like this:
> gph_inclass()
Error in gph_inclass() : could not find function "gph_inclass"
That error always means the same thing: run the source() line, then try again. Nothing is broken.
To stop typing it altogether, run gph_setup() and answer yes when it offers to load the commands automatically. Then restart R (Session > Restart R) and they will be there in every session from now on, in every project, even offline.
Once per computer: gph_setup()
gph_setup()It installs anything missing, asks for your name and email, and walks you through creating and storing a GitHub token. Run it again any time to confirm things are still connected; it is safe to repeat.
If you would rather understand each piece, the long version is in Connecting RStudio to GitHub.
Once per exercise: accept, then gph_start(N)
Accept the assignment. The link is on that week’s page, for example Weekly Exercise 2. This creates a private GitHub repository that belongs to you. Do it once per exercise.
Open it in RStudio. In the Console:
gph_start(2)Use the exercise number you are working on. That is the whole step: no URL to copy, no dialog to fill in, no folder to choose. It works out which repository is yours, downloads it into
~/gph2182, and opens it as a project.
If you have not accepted yet, gph_start() says so and prints the link you need.
Wherever you already keep your course work. gph_start() looks at where your other course projects live and puts the new one beside them, so if your folder is called ~/NYU/stats or ~/grad/fall2026, that is where it goes. If you have none yet, it asks once and remembers the answer.
It also never makes a second copy: if you already have that exercise, it opens the copy you have and tells you where it is.
To keep them somewhere else, pass the folder once and it is remembered:
gph_start(3, where = "path/to/your/folder")And the safety net: if you already have an exercise open, you do not need gph_start() at all. gph_check() and gph_submit() work from inside any copy of the repository, wherever it lives.
Once for the whole semester: your in-class repository
In-class exercises are different from the weekly exercises. They all live in one repository that you set up once and reuse every week.
Accept the in-class assignment on Classroom 50. Once, for the semester.
In the Console:
source("https://gph-2182.github.io/gph2182.R") # unless already loaded gph_inclass()
Each week, from inside that project, fetch the worksheet with the week’s number:
source("get_worksheet.R"); get_worksheet(3)Then add both partners’ names, do the work, and commit and push before the end of class.
It has to be the one Classroom 50 makes, because that is the copy owned by the class and visible to the instructor. A repository you create under your own GitHub account is invisible to us, and if it is public your classmates can read your answers. If you have already made one by hand, run gph_inclass() to get the proper one and copy your worksheet files across.
Then repeat: edit, check, submit
Edit
Open exercise.qmd. Put your name in the author: field. Answer each question by replacing NULL with your code.
Keep the object names exactly as given (q1, q2, and so on). The checks look for those names, so renaming them loses points even when your code is right.
Check
gph_check()This runs the same checks GitHub will run, on your machine, in about two seconds. You get a PASS or FAIL line per question. Fix the FAIL lines and run it again. Nothing is submitted and nobody sees the result.
gph_check() runs in a separate, clean R session on purpose. That means it cannot be fooled by an answer that only exists in your Environment pane rather than in the file, which is the most common reason work passes locally and fails on GitHub.
Submit
gph_submit()One command does all of it: stages your files, commits them, pushes to GitHub, then waits for GitHub’s own check and tells you the result in the Console. You do not have to visit the Actions tab; the link it prints is clickable if you want to look.
It pauses for up to a couple of minutes at the end, and that is normal. Your work is already submitted by then; the wait is only for GitHub to report back. You can stop waiting at any time without affecting your submission.
What the results mean
| What you see | What it means | What to do |
|---|---|---|
Everything passes from gph_check() |
Your file is right on your machine | gph_submit() |
Pushed to GitHub |
Your work is submitted and safe | Wait for the check result |
everything passes. You are done. |
GitHub agrees. Finished | Nothing |
something still fails |
Your push arrived but a question is wrong | gph_check(), fix, gph_submit() |
Still running |
GitHub is busy | Wait a minute, then check the link it printed |
Submitting many times is normal and expected. Only your last push before the deadline is graded, so a failing check on an early attempt costs you nothing. Push early and often: work on GitHub cannot be lost.
When something goes wrong
gph_doctor()It prints a ✓ or ✗ for every single thing that has to be true, in order: packages, your Git name and email, your token, whether this folder is really a repository, whether anything is uncommitted, whether anything is unpushed, and what GitHub said about your last submission. The first ✗ is your problem, and each line tells you which command fixes it.
If you are still stuck, look the exact error message up on the error messages page, then send me or Sabrina the output of gph_doctor(). That output contains no secrets and usually makes the answer obvious in one reply.
Doing it by hand
The commands above are a convenience, not a hiding place. Git and GitHub are part of what this course teaches, and you should be able to do this without the helpers by the end of the semester.
- Clone: copy your repository URL from GitHub, then in RStudio File > New Project > Version Control > Git, paste the URL, choose your
~/gph2182folder, and click Create Project. - Edit: open
exercise.qmdand answer the questions. - Stage: in the Git tab, tick the box next to each changed file.
- Commit: click Commit, read the diff, write a message, click Commit.
- Push: click the green Push arrow. Then open your repository on github.com and click the Actions tab to see the result.
Each of these is explained in full in RStudio projects and cloning a repository and Committing, pushing, and pulling.
Every command, in one place
| Command | When |
|---|---|
gph_setup() |
Once per computer. Connects to GitHub and loads these commands in every session |
gph_inclass() |
Once for the semester. Opens your in-class repository |
gph_start(N) |
Once per exercise. Downloads and opens weekly exercise N |
gph_check() |
Every time. Runs the autograder’s checks on your machine |
gph_submit() |
Every time. Stages, commits, pushes, reports the result |
gph_doctor() |
When stuck. Checks everything and says what is wrong |
gph_help() |
Prints the list above |
That is the whole set. To keep projects in a folder of your own choosing, pass it to gph_start() once and it is remembered:
gph_start(3, where = "path/to/your/folder")