ascii (version 0.6-1)

ascii: Export R objects to several markup languages

Description

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

Usage

## S3 method for class 'default':
ascii(x, 
    include.rownames = TRUE, include.colnames = TRUE,
    rownames = NULL, colnames = NULL, 
    format = "f", digits = 2, decimal.mark = ".", na.print = "", 
    caption = NULL, caption.level = NULL, width = 0, frame = NULL,
    grid = NULL, valign = NULL, header = TRUE, footer = FALSE,
    align = NULL, col.width = 1, style = NULL, tgroup = NULL,
    n.tgroup = NULL, talign = "c", tvalign = "middle", tstyle = "h",
    bgroup = NULL, n.bgroup = NULL, balign = "c", bvalign = "middle",
    bstyle = "h", lgroup = NULL, n.lgroup = NULL, lalign = "c",
    lvalign = "middle", lstyle = "h", rgroup = NULL, n.rgroup = NULL,
    ralign = "c", rvalign = "middle", rstyle = "h", list.type =
    "bullet", \dots)
  ## S3 method for class 'ftable':
ascii(x, digits = getOption("digits"), header = TRUE, ...)
  ## S3 method for class 'summary.table':
ascii(x, caption = NULL, caption.level = NULL, list.type = "bullet", \dots)
  ## S3 method for class 'list':
ascii(x, caption = NULL, caption.level = NULL, list.type = "bullet", \dots)
  ## S3 method for class 'sessionInfo':
ascii(x, locale = TRUE, ...)
  ## S3 method for class 'smooth.spline':
ascii(x, caption = NULL, caption.level = NULL, list.type = "bullet", \dots)
  ## S3 method for class 'describe':
ascii(x, condense = TRUE, \dots)
  ## S3 method for class 'meanscomp':
ascii(x, header = TRUE, caption = NULL, include.rownames = TRUE,
    include.colnames = TRUE, \dots)
  ## S3 method for class 'CrossTable':
ascii(x, \dots)
  ## S3 method for class 'freqtable':
ascii(x, header = TRUE, footer = TRUE, digits =
    c(0, 2, 2), format = "f", na.print = "", include.rownames = TRUE,
    include.colnames = TRUE, caption = x$label, ...)
  ## S3 method for class 'survfit':
ascii(x, scale = 1,
    print.rmean = getOption("survfit.print.rmean"), rmean =
    getOption("survfit.rmean"), include.rownames = TRUE, include.colnames = TRUE,
    header = TRUE, ...)
  ## S3 method for class 'summary.survfit':
ascii(x, include.colnames = TRUE, header =
    TRUE, digits = c(0, 0, 0, 3, 3, 3, 3), ...)

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.
rownames
Character vector (replicated or truncated as necessary) indicating rownames of the corresponding rows. If NULL (default) the row names are not modified
colnames
Character vector (replicated or truncated as necessary) indicating colnames of the corresponding columns. If NULL (default) the column names are not modified
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 NULL.
caption.level
Character or numeric vector of length 1 containing the caption's level. Can take the following values: 0 to 5, "." (block titles in asciidoc markup), "s" (s
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
Vector or matrix indicating vertical alignment of all cells in table. Can take the following values: "top", "bottom" and "middle". Default is "".
header
logical or numeric. If TRUE or 1, 2, ..., the first line(s) of the table is (are) emphasized. The default value depends of class of x.
footer
logical or numeric. If TRUE or 1, the last line(s) of the table is (are) emphasized. The default value depends of class of x.
align
Vector or matrix indicating the alignment of the corresponding columns. Can be composed with "r" (right), "l" (left) and "c" (center). Default value is NULL.
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 or matrix indicating the style of the corresponding columns. Can be composed with "d" (default), "s" (strong), "e" (emphasis), "m" (monospaced),
tgroup
Character vector or a list of character vectors defining major top column headings. The default is to have none (NULL).
n.tgroup
A numeric vector or a list of numeric vectors containing the number of columns for which each element in tgroup is a heading. For example, specify tgroup=c("Major 1","Major 2"), n.tgroup=c(3,3)
talign
Character vector of length one defining alignment of major top column headings.
tvalign
Character vector of length one defining vertical alignment of major top column headings.
tstyle
Character vector of length one indicating the style of major top column headings
bgroup
Character vector or list of character vectors defining major bottom column headings. The default is to have none (NULL).
n.bgroup
A numeric vector containing the number of columns for which each element in bgroup is a heading.
balign
Character vector of length one defining alignment of major bottom column headings.
bvalign
Character vector of length one defining vertical alignment of major bottom column headings.
bstyle
Character vector of length one indicating the style of major bottom column headings
lgroup
Character vector or list of character vectors defining major left row headings. The default is to have none (NULL).
n.lgroup
A numeric vector containing the number of rows for which each element in lgroup is a heading. Column names count in the row numbers if include.colnames = TRUE.
lalign
Character vector of length one defining alignment of major left row headings.
lvalign
Character vector of length one defining vertical alignment of major left row headings.
lstyle
Character vector of length one indicating the style of major left row headings
rgroup
Character vector or list of character vectors defining major right row headings. The default is to have none (NULL).
n.rgroup
A numeric vector containing the number of rows for which each element in rgroup is a heading. Column names count in the row numbers if include.colnames = TRUE.
ralign
Character vector of length one defining alignment of major right row headings.
rvalign
Character vector of length one defining vertical alignment of major right row headings.
rstyle
Character vector of length one indicating the style of major right row headings
list.type
Character vector of length one indicating the list type ("bullet", "number", "label" or "none"). If "label", names(list) is use
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).
locale
default is TRUE to show locale information (sessionInfo()).
scale
A numeric value to rescale the survival time, e.g., if the input data to survfit were in days, scale=365 would scale the printout to years (see print.survfit() in package survival).
print.rmean, rmean
Options for computation and display of the restricted mean (see print.survfit() in package survival).
...
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.

Sometimes, arguments are not active, depending of the features implemented in the markup language generated. All arguments are active when asciidoc syntax is produced.

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")
print(ascii(tab), type = "rest")
print(ascii(tab), type = "org")
ascii(summary(tab))

Run the code above in your browser using DataLab