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 type 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:

check.png Syntax errors: If you write code that R can’t understand, you ...

Get R For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.