comment_width {commentr}R Documentation

Function to specify the width of the comment

Description

Helper function to the commet family of functions. Can take both numerical values as the width in characters or a prespecified standard through a character string.

Usage

comment_width(width = "option", a4portrait_width = 80)

Arguments

width

is the prefered width. Could be numeric (number of characters), a paper size (currently "a4portrait", "a4landscape", "a3portrait" or "a3landscape"), "script_width" (= getOption("width") - 5) or "option" (to get data from global option "comment_width"). Default is "option" but if a global option does not exist, "a4portrait".

a4portrait_width

specifies the number of characters that can be printed on a single line on a a4 paper in portrait orientation. This value is usually 80 (or in the range from 60 to 75). Here a lower value is set by default due to experimentation on the authors own computer. Please contact the author if this value seems strange. Note however that it is usully more sufficient to use a global option for the width parameter than to manually change this value (whih is however possible for increased flexibility). This value depends on margins and font size when printing.

Details

The width is specified in order to fit the comment on a printed page or in a script file showed in RStudio (hence the -5 in getOption("width") - 5 to adjust for the line numbering in the script file compared to the console. It is also possible to use a global option comment_width. This is not a standard option and has to be manually specified (for example in a .Rprofile-file).

Value

An integer specifiing the text width (in number of characters) to be used in a comment.

Examples

comment_width()
comment_width(42)
comment_width("a4portrait")

## Not run: 
# We can set a global option for the comment_width
options(comment_width = 80)
header_comment("Test", "A small test")

## End(Not run)


[Package commentr version 1.0.4 Index]