PSYC 201 Fundamentals Guide

Note

You should use this site as a self-guided walkthrough. Follow the instructions and read the materials on each page at your own pace. The site will also remain available as a reference after this workshop.

Welcome to the fundamentals workshop guide! This site will help you do the following:

  • Get your laptop setup with R, Python, git/github, and any other tools you need to have a smooth experience when doing data analysis and participating in Grad-Stats (201 A/B)
  • Walk-through the basics of R and/or Python
  • Offer some guidance of to think about working with AI in your graduate career

Getting started

The steps below will help you configure your personal laptop. If you’d rather just skip to playing with some R and Python code in your browser, head over to programming basics.

Just make sure to complete these steps below before 201a/b.

Tip

We’ll be making using of the macOS terminal for several steps below. Don’t be intimidated if you’ve never used it before or have limited experience! We’ve written the following instructions so you can follow along step-by-step and just copy-and-paste the commands to avoid typos. Though learning to navigate your computer using the terminal is a great skill to develop and will open up many things you can do. Like save yourself from dinosaurs.

Homebrew

First we’ll install the Homebrew a package manager for macOS. You can think of this like an “App store” for programs we run from our macOS terminal.

Use cmd+spacebar to search for an open a new Terminal then paste the following:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

After some long messages and setup you should have the brew command available. Check by typing which brew and seeing if you get any output. You should see something like:

> which brew
/opt/homebrew/bin/brew

Now we can use it to setup the rest of our tools.

Quarto

quarto is a modern scientific authoring tool you’ll use in PSYC 201 and your own research when you prepare labs, HWs, manuscripts.

Note

If you’ve already installed Quarto from the website or in the past, use which quarto to see if it’s already installed.
If so, feel free to skip the next command

brew install --cask quarto

This might take a while and ask you type your computer password into your terminal. You won’t see any input as you type, but just press enter after you do to continue the process.

Python

To keep all our tools reproducible and simple for collaborators and reviewers, we’ll use uv to manage our Python installation and any libraries in an isolated fashion.

brew install uv

You can confirm with which uv

R

To setup R just install the RStudio Desktop app following the official guide. We also highly recommend using the renv library to keep your project tools reproducible.

Version Control

Lastly we’ll want to make sure we have the latest tools to interact with git and github. First make a github account if you don’t already have one. Make sure to remember your email as you’ll need it in a moment.

Next make sure your computer has the latest version of git and the official github CLI tool:

brew install git gh

Now we’ll want to make sure the local git CLI program knows who we are. Run the following commands in your terminal (you won’t see any output):

git config --global user.name "your real name"
git config --global user.email "email associated with your github account"

We’ll also set a few other git options to avoid future headaches:

git config --global pull.rebase true

And

git config --global rebase.autoStash true

Now we can login to Github.com from our terminal to ensure that all our future work is associated with the same account:

gh auth login

Then you can answer the prompts with the following answers:

Where do you use GitHub? GitHub.com
What is your preferred protocol for Git operations on this host? HTTPS
Authenticate Git with your GitHub credentials? Yes
How would you like to authenticate GitHub CLI? Login with a web browser

You should see the following prompt with a unique code for you. Make sure to copy it and then press <enter>

First copy your one-time code: 4722-D256
Press Enter to open https://github.com/login/device in your browser...

Copy and paste the code into the browser page and press the green button to approve. When you’re all set you’ll get the following output with your Github userid:

✓ Authentication complete.
- gh config set -h github.com git_protocol https
✓ Configured git protocol
✓ Logged in as ejolly

You can verify your local setup by running git config --list and looking at the output for some sanity checks like your Github username & email:

user.name=ejolly
user.email=eshin.jolly@gmail.com
pull.ff=false
pull.rebase=false

IDE (general code editor)

While not strictly required, it’s nice to have a general purpose integrate-development-environment (IDE). The most popular by far is VSCode which is extremely flexible and works with Python, R, and many other languages and tools. It integrates a terminal, file-browser, and more so you have single program to work from across your projects.

Next Steps

You should be good to go! We recommend checking out the programming basics next. And you can run all the examples right from your web browser!

Back to top