Learn R Programming

R.utils (version 2.12.2)

VComments: The VComments class

Description

Package: R.utils
Class VComments

Object
~~|
~~+--SmartComments
~~~~~~~|
~~~~~~~+--VComments

Directly known subclasses:
LComments

public static class VComments
extends SmartComments

The VComments class.

Usage

VComments(letter="V", verboseName="verbose", ...)

Arguments

letter

The smart letter.

verboseName

The name of the verbose object.

...

Not used.

Fields and Methods

Methods:

convertCommentConverts a verbose comment to R code.
resetResets a VComments compiler.
validateValidates the compiled lines.

Methods inherited from SmartComments:
compile, convertComment, parse, reset, validate

Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save

Author

Henrik Bengtsson

Details

The 'v' in VComments stands for 'verbose', because of its relationship to the Verbose class.

Here is a list of VComments and the R code that replaces each of them by the compiler:

Constructors

  • #V0#[<args>] - NullVerbose(<args>)

  • #V1#[<args>] - Verbose(<args>)

Controls

  • #V=#[<variable>] - Sets the name of the <verbose> object. Default is 'verbose'.

  • #V^#<threshold> - setThreshold(<verbose>, <threshold>)

  • #V?#<expression> - if (isVisible(<verbose>)) { <expression> }

  • #V@#<level> - setDefaultLevel(<verbose>, <level>)

  • #Vm#<method> <args> - <method>(<verbose>, <args>)

Enters and exits

  • #V+#[<message>] - enter(<verbose>, <message>)

  • #V-#[<message>] - exit(<verbose>, <message>)

  • #V!#[<message>] - pushState(<verbose>)
    on.exit(popState(<verbose>))
    If <message>, enter(<verbose>, <message>)

Simple output

  • #Vn#<ignored> - newline(<verbose>)

  • #Vr#<ignored> - ruler(<verbose>)

  • #Vt#<ignored> - timestamp(<verbose>)

  • #Vw#[<title>] - warnings(<verbose>, <title>)

Output messages

  • #Vc#[<message>] - cat(<verbose>, <message>)

  • #Ve#<expression> - eval(<verbose>, <expression>)

  • #Vh#<message> - header(<verbose>, <message>)

  • #Vp#<object> - print(<verbose>, <object>)

  • #Vs#<object> - summary(<verbose>, <object>)

  • #Vz#<object> - str(<verbose>, <object>)

Examples

Run this code
filename <- system.file("data-ex/exampleVComments.R", package="R.utils")
lines <- readLines(filename)

cat("Code before preprocessing:\n")
displayCode(code=lines, pager="console")

lines <- VComments$compile(lines)

cat("Code after preprocessing:\n")
displayCode(code=lines, pager="console")

Run the code above in your browser using DataLab