File systems and the command line

Session 3

September 10, 2024

Review of last session

  • What questions do you have?
  • What happened as you were trying to re-organize projects or R code?
    • Victories?
    • Stumbling blocks?

Learning objectives

  • Understand your computer’s file system
  • Understand the what and why of the shell command-line interface
  • Use the CLI to navigate your computer’s file system
  • Use the shell and file system navigation within RStudio
  • Know your options for finding help

How well do you know your file system?

Example file system

Example file system

How do you navigate your file system?

  • Searching
  • Point and click
  • “Go to path”

How do we navigate the file system programmatically?

  • A script can’t point and click!
  • We need a system for moving around our file system through written commands.

What is the shell?

  • Command-line interface, in contrast to a GUI
  • Useful for navigating the file system
  • …and for automating large tasks (e.g. renaming, moving files)
  • and for running programs that may not have a GUI
  • and for interfacing with remote computers (e.g. the HPC)

Shell in this workshop

  • git/GitHub (next 2 lessons)
  • Navigating your file system
  • Quarto (lesson 2)

Let’s get set up!

  • macOS comes with a shell (usually Bash or zsh) built-in

  • Windows need to install GitBash (includes Bash shell and git, which we will use later)

  • Breakout rooms

    • Mac users go with Eric
    • Windows users go with Renata

Data download

Coding time

  • RStudio panes
  • Set up Terminal in RStudio
  • Navigation using Terminal and Files pane

Syntax of a shell command

Coding time

  • Synchronize working directories between Terminal, Files Pane, and R working directory

Coding time

  • Use an RStudio project to simplify working directories
  • Copy shell_lesson_data to your R project

Getting help

ls --help
man ls

Getting help

git --help

Getting help

Getting help

Getting help: fellow humans

Getting help: fellow humans

Takeaways

  • The shell is a command-line interface to the computer
  • The file system the shell sees is the same as your File Explorer tab
  • We can use the shell from the Terminal pane in RStudio
  • Find help from built-in manual pages, Google, (maybe) AI tools, or community

Break

Reproducibility colloquim check-in

  • Breakout rooms of 3-4

Check-in questions

  • What project are you going to be focusing on for the reproducibility colloquim?
  • In which areas do you think it will benefit the most from a makeover?
    • Project organization
    • Collaboration practices (git, github)
    • Code efficiency and robustness (functions, iteration)
    • Documentation
  • What kinds of support will help you make those improvements?

Homework for next time

Resources: Shell

Resources: UA community