Intro to Practical Computing

Practical Computing and Data Science Tools

Agenda

  • Review
  • Naming best practices
  • Files and directories

Last week

  • Syllabus
  • Lab 1
  • Tools for the course: R, RStudio, and Quarto

Syllabus

  • Recall lecture tickets are due in person at the beginning of lecture.
  • Course late policy has been added to online version.
  • Let’s quickly review the late policy.

www.for128.org/syllabus.html

Lab 1

  • If you’re having troubles, technical or otherwise, come to office hours.
  • Make sure to turn in (.pdf and .qmd) to D2L by 5pm on Wednesday (tomorrow).

Data Science Tools

  • R is a programming language.
  • RStudio is an IDE (what we use to interact with R and our computer).
  • Quarto is a markdown language, for writing reports.
  • You, the chef
  • R, the ingredients
  • RStudio, your kitchen
  • Quarto, the plated final product

Practical computing

Practical computing

  • Understanding your computer and its file system is vital to success in this class and beyond.

  • Last week, we threw you into the deep end with data science tools.

  • This week, we’ll spend a bit more time on the details to help you interact with your computer and these tools.

  • Today, we’ll focus on file systems and file/folder naming.

Naming files and folders

Some best practices are important for naming files and folders:

  • Use consistent casing:
    • delimiter naming, e.g. lab_01.qmd or cat_pictures
    • camel case, e.g., finalProjectMaterials.qmd or catPictures
  • Name your files and folders clearly, concisely, and informatively:
    • Good: for128_f24
    • Bad: my_work_for_forestry128_in_fall_2024
    • Really bad: myWorkFor_forestry128_inFall_2024

File systems / directories

  • Every time you create or download a file, you are storing it somewhere in your computer’s file system.
  • But where? 🤔

File systems / directories

  • Think of your computer’s file system as a tree

The root

The root directory is the start or base of your file system.

  • On Windows, the root is C:/
  • On macOS and Linux, the root is /

Your home directory

When interacting with your computer, you are logged in as a user. Each user has a home directory.

For example:

  • On Windows, C:/Users/Sarah
  • On macOS and Linux, /home/sarah

Your home directory

It is often easier to use a shortcut to access your home directory: ~. On Windows, macOS, and Linux, you can use ~ to access your home directory:

  • ~ is equivalent to C:/Users/Sarah and /home/sarah

Paths

C:/Users/Sarah and /home/sarah are examples of paths. In particular, these are paths to Sarah’s home directory.

Paths

  • Paths specify the location of a file or folder on your computer, let’s look at a few examples:
    • /
    • /home/sarah
    • /home/sarah/Desktop
    • /home/sarah/Documents/for128/lab_01.qmd
    • ~/Documents/for128/lab_01.qmd

Paths

  • Equivalent paths, on Windows:
    • C:/
    • C:/Users/Sarah
    • C:/Users/Sarah/Desktop
    • C:/Users/Sarah/Documents/for128/lab_01.qmd
    • ~/Documents/for128/lab_01.qmd

Relative vs. absolute paths

  • So far, we’ve only shown absolute paths.
  • Absolute paths show a file or folder in reference to your computer’s file system.
  • Relative paths, on the other hand, show a file or folder in relation to a working directory.

Working directory example

  • Recall the absolute path to lab_01.qmd:
    • /home/sarah/Documents/for128/lab_01.qmd
  • Say our working directory is the documents folder:
    • /home/sarah/Documents
  • Then the relative path to lab_01.qmd is:
    • for128/lab_01.qmd

Use relative (not absolute) paths!

Why?

  • Reproducibility!
    • They will work on any computer, not just your own.
  • Clear and concise.
  • But really, reproducibility.

Working directories in Quarto and R demo

What have we learned?

  • In Quarto, the default working directory is the folder where the quarto document lives.
    • Crucial note: this may be different than the working directory in your R console.
  • You can set your working directory in R with setwd()
    • Just for your R console, though. This does not apply to Quarto documents.
  • You can get your current working directory in R with getwd()

Next time

  • Remember, lab 1 is due tomorrow at 5pm on D2L.
  • RStudio projects.
  • Reading and writing data.