Print Nicely Formatted Comments for Use in Script Files

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

Example

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 = "erik.bulow@rccvast.se"
)
#> 
#> ######################################################################
#> #                                                                    #
#> # Purpose:       Just an example!                                    #
#> #                                                                    #
#> # Author:        Erik Bülow                                          #
#> # Contact:       erik.bulow@rccvast.se                               #
#> # 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 comment
line_comment("")
#> The comment has been copied to clipboard and can be pasted into a script file!
#> 
#> ######################################################################

Install it

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")

Global options

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.

News

commentr 1.0.3

  • Package moved to Bitbucket to conform with other cancercentrum packages
  • test updated to conform with new version of testthat

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("commentr")

1.0.4 by Erik Bulow, 2 years ago


Report a bug at https://bitbucket.org/cancercentrum/commentr/issues? status=new&status=open


Browse source code at https://github.com/cran/commentr


Authors: Erik Bulow


Documentation:   PDF Manual  


GPL-2 license


Imports stringr

Suggests testthat


See at CRAN