R Comments
Comments
Comments can be used to explain R code, and to make it more readable. It can also be used to prevent execution when testing alternative code.
Comments starts with a #
. When executing the R-code, R will ignore anything
that starts with #
.
This example uses a comment before a line of code:
This example uses a comment at the end of a line of code:
Comments does not have to be text to explain the code, it can also be used to prevent R from executing the code:
Multiline Comments
Unlike other programming languages, such as Java, there are no syntax in R for multiline comments. However, we can just insert a #
for each line
to create multiline comments: