R Comments

Comments are used for R code explanation.  R comments make the code more readable.  When testing alternate code we can also prevent execution using comments. In R programming comments starts with the # symbol. R language ignores everything that starts with the # symbol while executing the R code.

R Comments
R Comments types

Following are some examples to execute a comment in R language:

The above example shows a comment before a code line.

The above example shows a comment at the end of a code line.

Comments are not only used to explain the code but also used to prevent code execution.

Multiline R comments

There is no syntax for multiline comments in R, unlike other programming languages. To create a multiline comment we just need to insert a # symbol for each line.

The multi-line R comments Trick

There is also another way to add multi-line comments by using a false block in the if statement. Due to the False condition statement will not be interpreted.

if(FALSE) {  
   "R is a programming language that is used for statistical computing and graphics. 
R programming is similar to S programming. "  
# Program
a <-"Tutorials Art"