ascii (version 0.1.1)

ascii: Export R object to asciidoc or txt2tags

Description

Function converting an R object to an ascii object, which can then be printed with Asciidoc, txt2tags or textile syntax.

Usage

## S3 method for class 'default':
ascii(x, 
    include.rownames = TRUE, include.colnames = TRUE, 
    format = "f", digits = 2, decimal.mark = ".", na.print = "", 
    caption = "", width = 0, frame = "", grid = "", valign = "", 
    header = TRUE, footer = FALSE, align = "", col.width = 1, style = "", \dots)
  ## S3 method for class 'describe':
ascii(x, condense = TRUE, \dots)
  ## S3 method for class 'summary.table':
ascii(x, caption = "", list.type = "bullet", \dots)
  ## S3 method for class 'list':
ascii(x, caption = "", list.type = "bullet", \dots)
  ## S3 method for class 'smooth.spline':
ascii(x, caption = "", list.type = "bullet", \dots)

Arguments

x
An R object of class found among methods(ascii).
include.rownames
logical. If TRUE the rows names are printed. Default value depends of class of x.
include.colnames
logical. If TRUE the columns names are printed. Default value depends of class of x.
format
Character vector of length equal to the number of columns of the resulting table (otherwise it will be replicated or truncated as necessary) indicating the format for the corresponding columns. These values
digits
Numeric vector of length equal to the number of columns of the resulting table (otherwise it will be replicated or truncated as necessary) indicating the number of digits to display in the corresponding columns.
decimal.mark
The character to be used to indicate the numeric decimal point. Default is ".".
na.print
The character string specifying how NA should be formatted specially. Default is "".
caption
Character vector of length 1 containing the table's caption or title. Set to "" to suppress the caption. Default value is "".
width
Numeric vector of length one containing the table width relative to the available width (expressed as a percentage value, 1...99). Default is 0 (all available width).
frame
Character vector of length one. Defines the table border, and can take the following values: "topbot" (top and bottom), "all" (all sides), "none" and "sides" (left and rig
grid
Character vector of length one. Defines which ruler lines are drawn between table rows and columns, and can take the following values: "all", "rows", "cols" and "none". Defa
valign
Character vector of length one indicating vertical alignment of all cells in table. Can take the following values: "top", "bottom" and "middle". Default is "".
header
logical. If TRUE the first line of the table is emphasized. The default value depends of class of x.
footer
logical. If TRUE the last line of the table is emphasized. The default value depends of class of x.
align
Character vector of length one indicating the alignment of the corresponding columns. Can be composed with "r" (right), "l" (left) and "c" (center). Default value is "".
col.width
Numeric vector of length equal to the number of columns of the resulting table (otherwise it will be replicated or truncated as necessary) indicating width of the corresponding columns (integer proportional values).
style
Character vector of length one indicating the style of the corresponding columns. Can be composed with "d" (default), "e" (emphasis), "m" (monospaced), "a" (cells can cont
condense
default is TRUE to condense the output with regard to the 5 lowest and highest values and the frequency table (describe() in package Hmisc).
list.type
Character vector of length one indicating the list type ("bullet", "number" or "none"). Default is "bullet".
...
Additional arguments. (Currently ignored.)

Value

  • This function returns an object of class c("ascii","proto","environment").

Details

The nature of the output generated depends on the class of x. For example, summary.table objects produce a bulleted list while data.frame objects produce a table of the entire data.frame.

All arguments are active when Asciidoc syntax is produced. Whith txt2tags, grid, valign, col.width and style are inactive.

The available method functions for ascii are given by methods(ascii). Users can extend the list of available classes by writing methods for the generic function ascii. All method functions should return an object of class c("ascii","proto","environment").

See Also

print.ascii

Examples

Run this code
data(esoph)
ascii(esoph[1:10,])
tab <- table(esoph$agegp, esoph$alcgp)
ascii(tab)
print(ascii(tab), type = "t2t")
ascii(summary(tab))

Run the code above in your browser using DataCamp Workspace