Package 'bannerCommenter'

Title: Make Banner Comments with a Consistent Format
Description: A convenience package for use while drafting code. It facilitates making stand-out comment lines decorated with bands of characters. The input text strings are converted into R comment lines, suitably formatted. These are then displayed in a console window and, if possible, automatically transferred to a clipboard ready for pasting into an R script. Designed to save time when drafting R scripts that will need to be navigated and maintained by other programmers.
Authors: Bill Venables <[email protected]>
Maintainer: Bill Venables <[email protected]>
License: GPL (>= 2)
Version: 1.0.0
Built: 2024-11-15 04:21:22 UTC
Source: https://github.com/cran/bannerCommenter

Help Index


Transfer text strings to the clipboard ready for paste

Description

This is only guaranteed for Windows; in the case of Linux you will need to have the xclip command installed and visible on the PATH and for Mac OS you will need to have pbcopy similarly available. In any case the transfer to the clipboard is only activated while in an interactive session.

Usage

copy_to_clipboard(x, ..., file = con)

Arguments

x

a characeter string vector

...

additional arguments as for cat

file

a file or connection (usually left at the default)

Details

It behaves like base::cat but differs in three respects.

First, if file is left missing, in an interactive session, the default file is a clipboard device, if possible.

Second, the return value is invisible(x) rather than invisible(NULL) as it is for base::cat.

Third, it only has a copying side-effect if used in an interactive session. In a non-interactive session it merely returns the x argument, invisibly.

Note the on Windows the function utils::writeClipboard offers a much more extensive range of possibilities for communicating with the clipboard device, but this facility is only available on Windows.

Value

x, invisibly (as for a print method)


Print method for banner objects

Description

As well as printing the comment string in the console window the same text strings are transferred to a clipboard, if possible, ready for pasting into the R script currently being drafted.

Usage

## S3 method for class 'banner'
print(x, ...)

Arguments

x

A character string vector as procuced by banner()

...

Not used

Value

x itself, invisibly. A side effect is that x is transferred to a clipboard device, if possible


Functions for YAML comments

Description

A facility for generating a comment block for inserting at the top of an R script to insert a yaml header and for setting chunk options within scripts to use the RStudio facility for automatically rendering scripts into documents.

Usage

yaml_header(title, author, ...)

chunk_options(...)

Arguments

title

A character string; if omitted may be supplied via the console

author

A character string; if omitted may be supplied via the console

...

Extra arguments, for yaml_header currently ignored; for chunk_options comma separated chunk options

Value

An incomplete yaml header, or a line of chunk options, in the clipboard by default

Examples

yaml_header(title = "My script",
            author = "Bill Venables")
chunk_options(comment="",
              fig.height=7,
              fig.width=8,
              out.width="90%")