"continuous" comment

Good morning. I have a question.

In R there is the possibility to define where a comment begins and where does it end without having to write "#" in each line?

for example in java you can use the two slashes // to comment on each line or you can put / * where the comment starts and * / where it ends.
Is there anything similar on R?

To my knowledge, R doesn't have an official multi-line commenting technique, but there are lots of workarounds listed in this thread:

3 Likes

As far as I know, there is no such possibility.

But if your problem is to type # in each line, then I can suggest there's two possible workarounds. Mind that these two are possible in Rstudio, and at least not in native R.

  1. You can write your multiline comments without #. Then select all these lines and use Ctrl + Shift + C to comment all these lines simultaneously.
  2. In editor, you can start the first line of your multiline comment by #'. Then, as you finish that line and continue to the next line by pressing Enter , #' will automatically appear in the next line and so on, until you remove it manually after the very last line of your comment.

Hope this helps.

Edit:

I'm sorry for the repetition of same answer. I started typing before Mara posted, and didn't notice her post before publishing it. Sorry.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.