Names and Values

Mini-Lecture 1

Ben Baumer

Smith College

2024-09-03

The course

Things you already know

  • data wrangling (i.e., dplyr)
  • data visualization (i.e., ggplot2)
  • universal programming concepts
    • data types
    • how to write a function
    • object-oriented programming?
  • basic version control (i.e., GitHub)

Things you will learn

  • how R really works
  • how to actually write robust, user-friendly functions
  • how to actually collaborate on GitHub (using pull requests and code review)
  • how to make your code:
    • readable
    • efficient
    • robust
  • how to write an R package

The first time

How it started…

How it ended!

Textbook 1 (required)

Textbook 2 (required)

Assignments & Grading

  • Daily practice:
    • Engage with the Lectures
    • Take the Quizzes
    • Do the Labs
    • Read the books!
  • Process: Make a pull request
  • Build: Write an R package
  • Reflect: 3 1-on-1 conferences

Use of generative AI

  • You can use generative AI, but…
  • …I mostly care about what you’ve learned

Warning

Remember that generative AI is not intelligent, doesn’t think, and has no idea what is true or false. You are solely responsible for the veracity of anything (e.g., code or text) you submit.

Resources

Computing

  • We’ll be doing lots of it!

  • Please bring a laptop to class

  • DM me Slack if you don’t have one

  • Chromebooks are OK

  • Don’t email me!

Let’s get started!

lobstr

Memory usage

library(lobstr)
mem_used()
42.03 MB
  • How is memory usage affected by:
    • loading packages
    • loading data sets
    • manipulating data

Memory of objects

obj_size(5)
56 B
obj_size(rnorm(100))
848 B
obj_size(dplyr::starwars)
42.29 kB
obj_size(dplyr::select)
1.31 kB
  • How much memory do individual objects occupy?

Memory locations

ref(mtcars)
█ [1:0x561bffc0b8a8] <df[,11]> 
├─mpg = [2:0x561bfd06e240] <dbl> 
├─cyl = [3:0x561bfcded150] <dbl> 
├─disp = [4:0x561bfcad6050] <dbl> 
├─hp = [5:0x561bfef77920] <dbl> 
├─drat = [6:0x561bfdb7cd00] <dbl> 
├─wt = [7:0x561bfcaa4e60] <dbl> 
├─qsec = [8:0x561bfea67fa0] <dbl> 
├─vs = [9:0x561c01f534c0] <dbl> 
├─am = [10:0x561bfc92bc30] <dbl> 
├─gear = [11:0x561bfefae0e0] <dbl> 
└─carb = [12:0x561bfc82bdb0] <dbl> 
  • where are objects stored in memory?

Addresses

Aside

A quick timeline

Now

Work on