Functions to produce nicely formatted comments to use in R-scripts (or Latex/HTML/markdown etc). A comment with formatting is printed to the console and can then be copied to a script.
R package to create script comments
library(commentr)header_comment("Just an example!","Just want to show a script header that can be copied to an R script",author = "Erik Bülow", contact = "[email protected]")#>#> #######################################################################> # ##> # Purpose: Just an example! ##> # ##> # Author: Erik Bülow ##> # Contact: [email protected] ##> # Client: Erik Bülow ##> # ##> # Code created: 2016-03-19 ##> # Last updated: 2016-03-19 ##> # Source: /Users/erikbulow/commentr ##> # ##> # Comment: Just want to show a script header that can be copi ##> # ed to an R script ##> # ##> ######################################################################block_comment("A small block comment")#> The comment has been copied to clipboard and can be pasted into a script file!#>#> #######################################################################> # ##> # A small block comment ##> # ##> ######################################################################line_comment("Comment on one line")#> The comment has been copied to clipboard and can be pasted into a script file!#>#> ######################## Comment on one line ########################## Comment line without commentline_comment("")#> The comment has been copied to clipboard and can be pasted into a script file!#>#> ######################################################################
The package can be downloaded from CRAN
install.packages("commentr")
The latest development version can also be downloaded from Bitbucket using the devtools package:
devtools::install_bitbucket("cancercentrum/commentr")
This package can use global options to streamline your commenting. See ?commentr
in R for details. If you have an .Rprofile
file (Google it if you do not know) you are recommended to add the following lines to it:
options(
name = "Your name",
contact = "Your contact details",
comment_width = 80
)
where 80 (change to preferd integer) is used as default for argument width
in function comment_width
.