How to show error line number in R studio

r, rstudio, syntax-error

Solution

First, have a look at `?traceback`.

There are many ways to debug R code/script. This is only one example.

In RStudio, from the `Debug` drop down menu option `On Error`, choose `Error Inspector` for (what I think is) the easiest debug mode for finding the line number of an error/bug. You can also choose `Break in Code` to show the highlighted line of an R script that contains the error.

When the error occurs, you can click either of the small areas marked `Show Traceback` and `Rerun with Debug`. The screen shot below shows the effect of clicking "Show Traceback" (hence it now says "Hide Traceback"). It tells me that the error occurred when R attempted to call `sample` (the third call). `LENGTH` had not yet been defined.

Problem

Is it possible to see the syntax error or runtime error line number (highlight also) generated after running the code in R studio? I searched the options but couldn't find.

Original source

Related problems