To Err is Human:

Understanding Error Messages in R

😨 + 💻

Jasmine Dumas | @jasdumas | jasdumas.github.io

November 6, 2016

Relevant Quotes

“to err is human; to forgive, divine” - Alexander Pope, “Essay on Criticism”

“to err is human; to really screw up, you need a computer” - Internet

“Programs must be written for people to read, and only incidentally for machines to execute.” ― Harold Abelson, Structure and Interpretation of Computer Programs

Presentation overview

Intended audience

Introduction

Everyone makes mistakes

All the feels! | Describe your feelings about this picture

B.R.I.E Method 🧀

Common Sources of Error Messages

Data types & structures

Error #1: non-numeric argument to binary operator

name_string = "Jasmine"
name_string * 2
## Error in name_string * 2: non-numeric argument to binary operator

Error #2: invalid ‘type’ (character) of argument

vec <- c(1, 2, 3, 4, 5, "hello world")
sum(vec)
## Error in sum(vec): invalid 'type' (character) of argument

Data wrangling

Error #3: all arguments must have the same length

df <- data.frame("age" = c(32, 31, 34), 
                 "pet" = c(F, T, T), 
                 "name" = c("Adam", "Blake", "Anders"))
table(df$age, df$pets)
## Error in table(df$age, df$pets): all arguments must have the same length

Additional Learning Resources

Questions & Discussion!