2

When running Sweave from emacs-ess, errors are provided with a code chunk number. Is there an easy way to navigate among the code chunks by number? Otherwise, they are difficult to identify.

David LeBauer
  • 31,011
  • 31
  • 115
  • 189

3 Answers3

5

I don't use emacs-ess (I use Eclipse/ StatEt) but this shows which code chunks are being processed by label (each code chunk starts with <<label="Some Text"... Does your code chunks include labels ?

PaulHurleyuk
  • 8,009
  • 15
  • 54
  • 78
  • So far, counting chunks worked for me. But I may consider using labels from now on. – Roman Luštrik Dec 22 '10 at 08:58
  • 1
    I agree. Labels are the way to go. I label most code blocks. In addition to aiding debugging, you can reuse code blocks, and importantly, it helps with the general readability of your Sweave document. – Jeromy Anglim Jan 01 '11 at 13:18
2

In noweb mode in emacs M-n i inserts the chunk and asks for the label. You can navigate between them with M-n g which is very handy with completion packages like ido or icicles. With ido you must use this hack to activate it for all completion-read based functions such as noweb-goto-chunk from above.

VitoshKa
  • 8,387
  • 3
  • 35
  • 59
1

Another thing that might help is setting options(error=recover) in your R environment before sweaving. That will give you a chance to investigate the state of things just before an error is thrown.

Neil Best
  • 817
  • 9
  • 17