The Open Workspace

Week 2 · Chapter 2

Today’s Agenda

  • What tonight is for, and why it is the least enjoyable evening of the semester
  • Why only 36 percent of studies could be redone
  • Reproducibility defined, and why code beats clicking
  • The four tools, one at a time, and the order to install them
  • Your GitHub account, your workspace folder, and the setup check
  • The assigned article, Wilson et al. (2017), and the discussion built on it
  • First contact with the example data

What Tonight Is For

  • By the time you leave this room you will have four programs installed and talking to each other, and one file that proves it
  • That is the whole goal. Everything else on these slides explains why we bother

The Least Enjoyable Evening of the Semester

  • Installing software is not research. It is the tedious part that makes research possible
  • Something will break for somebody in this room. It happens every section, every term
  • When it breaks it is not a verdict on you. It is one version number disagreeing with another
  • We fix it together, tonight, in the room. That is why we do it here and not at home

The Reason, in One Sentence

Six weeks from now you will look at a number in your own draft and not remember where it came from.

Everything tonight exists to make that impossible.

What That Looks Like at Scale

Open Science Collaboration, 2015

  • 270 researchers set out to redo 100 published psychology studies
  • They used the same published methods, similar participants, and the same analyses
  • Only 36 percent replicated at conventional thresholds
  • Among those that did, effect sizes averaged about half the original
  • These were not careless people. Their work simply was not built to be retraced

Two Words From That Study

Replication: running a study again with new data to see whether it reaches the same answer. Example: the 270 researchers redid each study with new participants.

Effect size: how big a difference or a relationship is, on a scale that does not grow with the sample. Example: the replications found effects about half the size the originals reported.

What Blocked Them Was Friction, Not Fraud

  • Methods sections did not say enough to re-run the analysis
  • Researchers had to email the original authors to ask
  • Some authors had moved, and some had lost the data
  • Some had used software whose menus had since changed

Reproducibility, Defined

Reproducibility: getting the same results again from the same data, the same code, and the same steps. Example: anyone who renders your file on the example data gets your exact message counts.

  • It is not a virtue. It is a property of how you stored your work
  • The test is small and personal: can you recover, six months from now, exactly what produced a number?

Why Clicking Loses

  • SPSS, Excel, and JMP work through menus and dialog boxes
  • You click Analyze, then Compare Means, then One-Way ANOVA, and the result appears
  • The click history vanishes
  • Redoing it next month means remembering which menus, in what order, with which options
  • Writing it down means describing every click in prose, and nobody does this well

The course’s VS Code menus are different: each one writes its R code into your script, so the record stays.

Why Code Wins

  • A script is a description of every step, in a language a computer can re-run
  • The code is the methods section. That is the entire argument for everything we install tonight
  • Reinhart and Rogoff, the spreadsheet error from last week, was caught only because the file was eventually shared
  • Written as code, it would have been visible from the first day

Tool 1 of 4: VS Code

VS Code: a free code editor from Microsoft, where you write code and prose in one place.

  • What it does for you: it is the one window where everything lives
    • Your writing, your code, your files, and your output, so you stop alt-tabbing between five programs
  • You will spend more time in this than in anything else this term. It is the desk, not the work

Tool 2 of 4: R

R: a free language and environment for statistical computing and graphics.

  • What it does for you: it counts things, tests things, and draws charts, and it leaves a written record of having done so
  • You are not becoming a programmer. You are learning to drive one tool for one job, the way you learned to drive a citation manager

Tool 3 of 4: Quarto

Quarto: an open-source publishing system that turns one file of text and code into a finished website, PDF, or paper.

  • What it does for you: you write one file holding both your prose and your code, press render, and it produces a finished document with the charts already in place

Render: telling Quarto to run the code in your document and build the finished file from it. Example: rendering your White Paper redraws every chart from the current data.

  • You never again paste a chart into Word, find an error, redo the chart, and paste it again

Tool 4 of 4: Git and GitHub

Git: a program that tracks every change to the files in a project, so you can see or return to any earlier version. GitHub: a website that hosts those Git projects online.

  • What it does for you: an undo button that reaches back months, and proof of when you did what
  • It is also the closest thing our field has to a portfolio. Employers look, so use a professional username

Install in This Order

  1. R, from cran.r-project.org
  2. VS Code, from code.visualstudio.com
  3. The R extension inside VS Code, by REditorSupport
  4. Quarto, from quarto.org
  5. The Quarto extension inside VS Code
  6. Git, from git-scm.com
  7. The AURA Lab R Companion inside VS Code: Extensions view > search AURA Lab R Companion > Install

Why This Order

  • Click a name on the previous slide to open its download page. Steps 3, 5, and 7 happen inside VS Code, not in a browser
  • The order is not decorative. Each one looks for the one before it and gets confused when it is missing

Make Your GitHub Account

  • GitHub is a website that stores your files and their history. Git is the program on your laptop, and GitHub is the copy online
  • You need the account before Git is any use to you
  1. Sign up at github.com/signup. Choose a professional username, because employers will read it
  2. Add a profile photo and a short profile README saying who you are and what you study
  3. Claim the free Student Developer Pack with your SIUE email

The pack includes GitHub Copilot. The course workspace tells Copilot Chat to write tidyverse code with %>% and to remind you to log each exchange in your AI-use log.

The Hub walks through it one step at a time: GitHub Setup

Packages, the Tidyverse, and the Pipe

Package: a bundle of functions, data, and help pages that adds to what R can do on its own. Example: the course’s v2v package adds the example Twitch data and setup().

Tidyverse: a collection of R packages for data science that share one design and are built to work together. Example: library(tidyverse) loads its core packages at once, including dplyr for tables and ggplot2 for charts.

Pipe (%>%): read it as “and then”; it hands the result of one line to the next. Example: chat %>% filter(channel == "bobross") takes the chat table, then keeps Bob Ross’s messages.

Three Git Words

Repository (repo): a project folder that Git tracks, holding your files and the full history of every change to them. Example: the mc501-workspace folder you make tonight.

Clone: a copy of a repository that lives on your own computer, linked to the copy on GitHub. Example: the mc501-workspace folder that Git: Clone puts on your laptop.

Commit: a saved change to your files in Git, recorded with who made it, when, and a short message saying what changed. Example: “Add the first draft of my research questions.”

Make Your Workspace Folder

One folder holds everything you write this term. You copy ours rather than building it.

  1. Open the v2v-workspace template
  2. Click the green Use this template, then Create a new repository. Name it mc501-workspace and leave it Public
  3. In VS Code press Ctrl+Shift+P, or Cmd+Shift+P on a Mac, type Git: Clone, press Enter, and paste your new repository’s URL
  4. When VS Code offers the workspace’s recommended extensions, click Install All. That includes the AURA Lab R Companion

You should see: your folder names down the left side of VS Code.

The Hub walks through it in more detail: Workspace Setup

Now Open the Setup File

  • It is already in your workspace, in the top folder: 00-check-your-setup.qmd. Click it
  • If you have no workspace yet, download the file on its own from the Resources page, or click it here: aura-lab.siue.edu/v2v-hub/starters/00-check-your-setup.qmd
  • It walks you through the rest, one gray box at a time, and it tells you what each box should print
  • Work through it, and ask the moment something looks wrong, not at the end

What “Working” Looks Like

The file finishes by running a checker we wrote for this course:

library(v2v)
setup()
  • You want a list of green check marks under Required R packages
  • Red marks next to Quarto or Git are expected tonight if you have not finished those steps
  • Red under Required is the one that needs me
  • Then open the Command Palette and run Check my setup. It runs the same checklist, and its Install what is missing action installs any package it flags

When It Breaks

  • Red text in R is not automatically an error. R prints ordinary progress in red, so read the last line, not the color
  • Close VS Code completely and reopen it. This genuinely fixes a lot
  • If R asks “which would you like to update,” choose 3: None. The install command on the Hub already skips that prompt
  • Run Check my setup from the Command Palette. Its Install what is missing action installs any missing package without the update question

When It Still Breaks

  • Send me the exact wording of the error, not a paraphrase. The wording is the diagnosis
  • Ask after fifteen minutes stuck, not after two hours
  • Still stuck? On github.com open your workspace repository, click Code, Codespaces, then Create codespace on main. R, the packages, and the Companion are already installed there

Discussion: Good Enough Practices

These questions are on “Good enough practices in scientific computing” (Wilson et al., 2017).

  • The title concedes something. State what work “good enough” is doing in it, and who it is for
  • Name one of their practices that would survive contact with your actual working habits, and one you would quietly abandon by October
  • They write for the researcher with no formal computing training. State whether that framing makes the advice more usable or lowers the ceiling, and why
  • Name one practice in the paper you think is oversold

First Contact With the Data

stream_log, November 2018

channel game viewers date
sodapoppin Marble It Up! 27,934 1542578200214
xqcow Just Chatting 19,381 1542578200240
forsen Artifact 15,300 1542578200273
giantwaffle Rocket League 4,697 1542578200423
sodapoppin Marble It Up! 28,076 1542578261145
xqcow Just Chatting 19,231 1542578261186

Look at the rows before reading on.

The Data Moves

Time series: a set of measurements of the same thing taken one after another over time. Example: four channels recur across these rows, so each one’s viewer count can be followed minute by minute.

  • Sodapoppin climbs from 27,934 to 28,076 to 28,203
  • That is 269 viewers in 122 seconds, an audience growing close to real time

What Moves the Numbers

  • xQc lost 150 between the first two snapshots and then held, and Forsen lost 120
  • Each number is a real moment: a clip went viral, a raid arrived, or bandwidth dropped

Raid: on Twitch, a streamer ending a stream by sending their viewers to another live channel. Example: a viewer count that jumps by hundreds in one minute.

The Timestamps Are Not Dates

Timestamp: the date and time something happened. Example: 1542578200214 is the first row’s timestamp, 9:56 PM on November 18, 2018 (UTC).

  • The date column is a thirteen-digit integer: 1542578200214
  • The next row, 26 milliseconds later, reads 1542578200240

Reading Epoch Time

Unix epoch time: time counted from midnight UTC on January 1, 1970; this data counts it in milliseconds. Example: the gap between sodapoppin’s first two rows is 60,931 milliseconds, about a minute.

Data wrangling: getting data into a form you can analyze, by tidying it (one row per case, one column per variable) and transforming it (keeping rows, adding columns, summarizing, joining tables). Example: turning these timestamp digits into dates, which Chapter 11 shows.

  • Converting the timestamps is a wrangling step, not a research question

Titles Are Themselves Data

  • xQc’s title is “RANK 1 GAMER ~ NO PLAN (help me),” which is a joke
  • Forsen’s title says he is giving away keys for a card game called Artifact
  • Giantwaffle’s title performs etiquette: “No Smoking in Chat”
  • One title carries a literal line break, because the streamer’s software let it through
  • These are content analysis opportunities sitting in a column you might dismiss as metadata

What the Package Gives You

  • twitch_chat_sample holds roughly 35,000 chat messages from a 50-channel corpus
  • twitch_streams_sample holds the stream snapshots for those channels, about 32,000 rows
  • Helper functions wrap loading, codebook skeletons, reliability metrics, and diagnostics
  • The helpers are not magic. They keep the concept from being buried under setup code
  • setup() re-runs any time you suspect an installation problem

Lock the Versions

renv: an R package that records the exact version of every package your project uses in a file called renv.lock, so those same versions can be installed again later. Example: a classmate who clones your workspace next year can rebuild your setup from renv.lock.

  • Without renv.lock, someone re-running your work next year may get different numbers, because a package changed underneath them
renv::init()

When to Lock Them

  • Run it before your first line of analysis code, and commit it before you collect your first data point

“Back up (almost) everything created by a human being as soon as it is created. This includes scripts and programs of all kinds, software packages that your project depends on, and documentation.”

Wilson et al. (2017, p. 12)

Before Week 3

  • Due Monday, September 7, 11:59 PM: your GitHub Profile, 25 points, with the stack installed and setup() passing
  • Read Chapter 3 (Ethics) and Chapter 4 (Intelligence Gathering) with the edition toggle on
  • Read the assigned article: Nosek et al. (2018), “The preregistration revolution”
  • Write your journal entry, 450 to 500 words, engaging both the chapters and the reading
  • Next week is searching. Bring a topic you might actually search

Questions, Comments, or Concerns?