Is it possible to annotate within an equation in R? For example:
100 /* item 1 */ + 200 /* item 2 */
giving an answer of 300.
I think /* */ is C code. Although, I am not certain 100 /* item 1 */ + 200 /* item 2 */ will run in C.
If I use 100 # item 1 # + 200 # item 2 # in R I get an answer of 100 because everything after the first # is ignored, as I expected.
I suppose I could use:
# item 1 item 2
100 + 200
I was just thinking that when equations become really long and complex taking up several lines it might be nice to annotate within an equation.
The following works and returns 300:
(100 + # item 1
200 ) # item 2
That requires a new line after every annotation and is the closest that I can come to my initial example above containing only one line.
Thanks for any advice.
It’s not possible. As noted in the Comments section of the R language manual, the only comment character is #. Everything from the # to the end of the line is ignored (unless the # is quoted in a string).