Identify the problem and make a plan

Last updated on 2024-11-19 | Edit this page

Overview

Questions

  • What do I do when I encounter an error?
  • What do I do when my code outputs something I don’t expect?
  • Why do errors and warnings appear in R?
  • Which areas of code are responsible for errors?
  • How can I fix my code? What other options exist if I can’t fix it?

Objectives

After completing this episode, participants should be able to…

  • decode/describe what an error message is trying to communicate
  • Identify specific lines and/or functions generating the error message
  • Lookup function syntax, use, and examples using R Documentation (?help calls)
  • Describe the general category of error message (e.g. syntax error, semantic errors, package-specific errors, etc.)
  • Describe the output of code you are seeking
  • Identify and quickly fix commonly-encountered R errors
  • Identify which problems are better suited for asking for further help, including online help and reprex

Predict the output from a base R function call

Which of the following results when running the following line of code:

R

length(5, 6, 7)
  1. 3
  2. Error in length(5, 6, 7) : 3 arguments passed to ‘length’ which requires 1
  3. NULL
  4. 1, 1, 1
  1. Error in length(5, 6, 7) : 3 arguments passed to ‘length’ which requires 1