Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show error line number in R studio

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.

like image 284
waheebyaqub Avatar asked Apr 22 '14 14:04

waheebyaqub


1 Answers

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.

enter image description here

like image 146
Rich Scriven Avatar answered Oct 10 '22 03:10

Rich Scriven