[Rd] Multi-line comments in R

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Aug 20 17:23:26 CEST 2015

On Wed, Aug 19, 2015 at 5:16 AM, Nathan Esau <nesau at sfu.ca> wrote:
> I was wondering why the decision was made long ago to never implement
> multi-line comments in R. I feel there are several argument to be made for
> why the R language should have multi-line comments.
> 1. Many programming languages (including some which are commonly used for
> statistics, such as python, matlab and SAS) have this feature.

 Python doesn't have a multi-line comment.

 You can use triple-quoted strings in Python to quote a large chunk of
text, which won't generate any bytecode and so has no executable

def foo(x)
 y = x * 2
 well what now
 lets have a comment

A similar thing is possible in R:

 foo = function(x){
    "this is a test.
you can comment"

However I don't know if this causes any executable effect - its
possible R evaluates the string in some way.... Anyone want to test.

Yes, you have to escape any string quote marks in your comment, but in
python you have to escape any triple-quote marks.


More information about the R-devel mailing list