To Err is Human:
Understanding Error Messages in R
😨 + 💻
Jasmine Dumas | @jasdumas | jasdumas.github.io
November 6, 2016
“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
name_string = "Jasmine"
name_string * 2## Error in name_string * 2: non-numeric argument to binary operator
+ (positive) or - (negative) in-front of a number.vec <- c(1, 2, 3, 4, 5, "hello world")
sum(vec)## Error in sum(vec): invalid 'type' (character) of argument
sum(). Only numeric or integer values can be summed.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
table() are not the same length which is required for cross tabulation. The spelling mistake (pet versus pets) actually has a length of 0 which is a mismatch from df$age which has a length 3 but the error message does not indicate that the column name was misspelled.