Debugging

Probably the most helpful and simple debugging technique is to use cat() to print to the R console. There are two main reasons why you should do this:

  • The first is to put in little messages to yourself—for example, cat("This branch of code executed").
  • The second is to print the properties of R objects if you are having problems relating to data structure, size, or type. The cat(str(x)) phrase is particularly useful, and will print a little summary of any kind of R object, whether it is a list, a dataframe, a numeric vector, or anything else.

The other useful method is a standard method of debugging in R, browser(), which can be put anywhere in your code. As soon as it is executed, it halts the application and enters debug mode ...

Get Web Application Development with R Using Shiny - Third Edition 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.