O'Reilly logo

R For Dummies, 2nd Edition by Joris Meys, Andrie de Vries

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10

Debugging Your Code

In This Chapter

arrow Discovering what warnings tell you

arrow Reading errors correctly

arrow Finding the bugs in your code

arrow Optimizing your debugging strategies

To err is human, and programmers fall into that “human” category as well (even though we like to believe otherwise!). Nobody manages to write code without errors, so instead of wondering if you have errors in your code, you should ask yourself where you have errors in your code. In this chapter, you discover some general strategies and specific tools to find that out.

Knowing What to Look For

A bug is simply another word for some kind of error in your program. So, debugging doesn’t involve insecticides — it just means getting rid of all types of semantic and/or logical errors in your functions.

Before you start hunting down bugs, you have to know what you’re looking for. In general, you can divide errors in your code into three different categories:

  • Syntax errors: If you write code that R can’t understand, you have syntax errors. Syntax errors always result in an error message and often are caused by misspelling ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required