I want to add hashtag # sign before many lines in r. How can I do it using a shortcut key?
R Studio: Highlight the text and use CTRL+SHIFT+C to comment multiple lines.
I know this is slightly different to the question asked but after multiple failed searches on stackoverflow for a solution to my question, all which ended up on this page, I thought I would add this for anyone in a similar situation. I was looking for a quick way (purely for aesthetic commenting reasons) to add a line of #### across a R script, rather than holding down the # button, I came across the bannerCommenter
package which I think is really useful. It also has other formats.
library(bannerCommenter)
#run the following command which saves the comment to clipboard
#then just paste on next line of script
banner("Section 1:", "Data input and initialization", emph = TRUE)
###########################################################################
###########################################################################
### ###
### SECTION 1: ###
### DATA INPUT AND INITIALIZATION ###
### ###
###########################################################################
###########################################################################
rather than multiple "#", i prefer to use ' (apostrof) between lines to disable it. for example:
'dim(train);dim(test)
names(train)
names(test)
str(train)
str(test)'
in R console, 5 lines above will return:
> 'dim(train);dim(test)
+ names(train)
+ names(test)
+ str(train)
+ str(test)'
[1] "dim(train);dim(test)\nnames(train)\nnames(test)\nstr(train)\nstr(test)"
>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With