How to show error line number in R studio
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.
Read more here: Source link