RStudio version 1.4.1106, R version 4.0.4 (2021-02-15).
The following is a two-line R fragment.
Select the two lines of code and try to comment them out using either the menus (Code > Comment/Uncomment Lines) or the shortcut key sequence (Ctrl+Shift+C).
I find that the lines are not commented out by the IDE.
Now do the same with the above fragment and select only the first line of code and attempt to comment them out using either the menus or the shortcut key sequence (Ctrl+Shift+C). I find that in this case the line is commented out by the IDE.
In general, selecting lines of code in an R fragment and commenting them (Ctrl+Shift+C) works only if the last selected line is not the last line of the code fragment.
However, if you place the cursor anywhere on the last line (i.e. "plot(pressure)") then Ctrl+Shift+C correctly comments out that last line.
Can anyone confirm the same behaviour?
There was a similar buglet like this reported in late 2017 in Weird behavior when trying to comment a selected line in a R Markdown doc - RStudio IDE - RStudio Community.