R - knitr | .Rnw | How to comment, to avoid compilation errors?

691 views Asked by At

Edit: I am using RStudio

Up till now, while commenting something, I was using % symbol. Alternatively, I am just using Ctrl+Shift+C shortcut, which results in commenting with % or %' (or # for chunks).

The problem is, even if I comment something, it still often causes compilation errors. Look at the part of screenshot below:

compilation error

Lines 1 to 23 are fully commented and document starts at line 24. However, even if parts of the code are commented out and shouldn't affect it, they for some reason still results in errors.

If I move code from lines 24to32 at the very beginning of the file, it compiles without problems. I thought that maybe there can't be comments at the beginning of the file, but looks like it's not an issue, as trying things like moving \documentclass{article} at the very beginning still results in errors, even though there are less of them.

How can I comment lines, so they won't be calling compilation errors?

1

There are 1 answers

0
Nadjib FODIL CHERIF On

First, Make sure that all the lines you don't need are "correctely"commented.

Then, i think that you can't put commented code on the top of your document, also avoid to put commented code on your document it's a lousy code.