I noticed the following behavior in RStudio. Consider this small piece of an R Markdown document:
## My doc
Doc with a chunk
```{r chunk}
print("foo")
getwd()
```
Suppose I want to comment the last line before the closing triple backticks, i.e., getwd()
in my example. If I just position the cursor anywhere on that line, then the comment shortcut Ctrl+Shift+C, or the Comment/Uncomment lines
item of the Code
menu work perfectly, and I comment my code. If however I selected the whole line before, using Ctrl+DownArrow, this doesn't work. It works, however, if there is an empty line between getwd()
and the closing triple backticks, i.e.,
## My doc
Doc with a chunk
```{r chunk}
print("foo")
getwd()
```
Of course it's not like I have to select the line with Ctrl+DownArrow to comment it: it's just an habit I got from using other Windows editors. However, I was wondering why it works this way.
> library(rstudioapi)
> versionInfo()
$citation
To cite RStudio in publications use:
RStudio Team (2016). RStudio: Integrated Development for R. RStudio, Inc., Boston, MA URL
http://www.rstudio.com/.
A BibTeX entry for LaTeX users is
@Manual{,
title = {RStudio: Integrated Development Environment for R},
author = {{RStudio Team}},
organization = {RStudio, Inc.},
address = {Boston, MA},
year = {2016},
url = {http://www.rstudio.com/},
}
$mode
[1] "desktop"
$version
[1] ‘1.1.383’