4  Basic Workflow

So you’ve got your project library folder, Z-drive data folder, and analysis repository set up. What now? In this brief chapter, we’ll walk through the loop that constitutes the basic workflow, along with some guidance on new situations that might come up.

4.1 Creating an Analysis Repo

An analysis repo is basically just an R project. You can set one up through the RStudio GUI, or with the usethis package. usethis also includes handy helpers for initializing a repository, so I tend to rely on it for each step.

usethis::create_project("my-project")

Then, open the project folder in your development environment (RStudio or VSCode), and run the following in your R console1.

usethis::use_git()
usethis::use_github(private = TRUE)

Assuming you have set up your Github credentials, your analysis repo will be up and running locally and remotely.

4.2 Narrowing the scope

As mentioned previously, git can do a lot. For this basic workflow, you’re only going to use three commands to make it run: git add git commit and git push. We assume you’re the only one working on the analysis repo. If you are collaborating with others, and especially if you are working on different aspects of the project at the same time, please reach out for more guidance if you’re feeling unsure.

4.3 The Basic Pattern

  1. Identify a task (like “link survey data”, “clean program records”, “explore demographics”)
  2. Write the code that completes the task (you’ve been here before)
  3. git add -A to stage your changes to the analysis repo
  4. git commit -m "link survey data" 2 to commit your changes with the message “link survey data” (use whatever task you’re actually doing)
  5. git push -u origin main to upload your local changes to the remote (github) repository.

This basic pattern is a simplified version of the Repeated Amend workflow pattern described in Happy Git. You’re welcome to use that pattern as well, or explore Branching and Merging.

4.4 What can I do now that I couldn’t before?

  • Ask for help: if you’ve run into a problem that you don’t feel equipped to solve, you can ask one of your colleagues (with access to the Z-drive data folder) to clone the analysis repo, run your code, and offer edits, advice, or whatever else would help.
  • Show your work: the analysis repo is less sensitive than the data folder, and so can be shown to any Blueprinter, whether they are on the project team or not.
  • Find solutions: get inspiration from other data analyzing printers using the same approach by borrowing their code.

  1. The R console, where you execute R commands, is not the same as the Terminal (a.k.a. Shell, Command Prompt) You may not have used the terminal before, but you should be able to access it within your RStudio interface. See again Happy Git for more detail.↩︎

  2. Do your best to include a commit message every time you make a commit. Git requires that every commit have an accompanying message, and if you don’t provide in the shell directly, it will send you to vim, a much more confusing program.↩︎