R itself does not provide multi-line comments like /* ... */ like C/C++/JAVA, but we also have other ways to achieve this method.
1. if statement
We can add a permanently false condition through an if statement, so that we can also achieve the purpose of multi-line comments.
if(FALSE) { ...... }
2. Use shortcut keys
This method of using shortcut keys is only available in RStudio. First select the line to comment out, and then press Ctrl+shift+C to comment out. This is actually the same as the single-line comment method, except that RStudio has helped us simplify it.
If you want to uncomment, you still select it first, and then press the shortcut key Ctrl+shift+C.
Supplementary: R language annotation problem
Single line comment: # comment
Multi-line comments: R does not provide multi-line comments
Alternative method: select the code that needs to be commented, and the shortcut key ctrl+shift+c. To cancel this comment, you only need to repeat it.
(Or select multiple lines of code that need to be commented, and then "Main Menu-code-Comment/Uncomment Lines")
The above is personal experience. I hope you can give you a reference and I hope you can support me more. If there are any mistakes or no complete considerations, I would like to give you advice.