# Important Notes for Debugging R Code

### Source References

To enable the complete functionality of the visual debugger for R, it is required that the R code you want to debug has the so called source references. The source references are information attached to the R code and allows StatET to detect where the code is coming from. See also R help of 'srcref'.

## Submit code to R

For best results it is recommended, that the option Enable extension for improved debug support of R code in StatET in the launch configuration of the R console is enabled (default setting).

Submit commands supporting the debugging functionality:

- The command Run File in R via Command / Run R-Script via 'source' in R creates source references. It also updates the breakpoint for the sourced file.
- The commands Run Entire Command in R and Run Function Definition in R create source references and installs breakpoints in the submitted R code. Furthermore these are the only commands supporting toplevel breakpoints.

All other submit commands, especially Run Selection in R / Run Selection/Current Line in R do not create source references. When sourcing files without using the submit command of StatET, source references are created (not the improved version), but breakpoints are not updated.

## R Packages

To attach source references to an R package, the R packages must be installed:

- directly from a folder containing the unpacked source package; and
- the environment variable `R_KEEP_PKG_SOURCE` must be set to `yes`

To enable the full functionality, the sources should be in a R package project with the correct package name in the Eclipse workspace.

## Sweave Files

Breakpoints in Sweave files works only when running the R code directly, not during the Sweave process.