ascii {ascii} | R Documentation |
Function converting an R object to an ascii
object, which can
then be printed with asciidoc, txt2tags, sphinx or org syntax.
## Default S3 method: ascii(x, include.rownames = TRUE, include.colnames = TRUE, rownames = NULL, colnames = NULL, format = "f", digits = 2, decimal.mark = ".", na.print = "", caption = "", caption.level = "", width = 0, frame = "", grid = "", valign = "", header = TRUE, footer = FALSE, align = "", col.width = 1, style = "", cgroup = NULL, n.cgroup = NULL, calign = "", cvalign = "", cstyle = "", rgroup = NULL, n.rgroup = NULL, ralign = "", rvalign = "", rstyle = "", ...) ## S3 method for class 'ftable': ascii(x, digits = getOption("digits"), header = TRUE, ...) ## S3 method for class 'describe': ascii(x, condense = TRUE, ...) ## S3 method for class 'summary.table': ascii(x, caption = "", caption.level = "", list.type = "bullet", ...) ## S3 method for class 'list': ascii(x, caption = "", caption.level = "", list.type = "bullet", ...) ## S3 method for class 'sessionInfo': ascii(x, locale = TRUE, ...) ## S3 method for class 'smooth.spline': ascii(x, caption = "", caption.level = "", list.type = "bullet", ...)
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 are passed to the formatC function. Use "d" (for integers),
"f" , "e" , "E" , "g" , "G" , "fg" (for
reals), or "s" (for strings).
"f" gives numbers in the usual xxx.xxx format; "e" and
"E" give n.ddde+nn or n.dddE+nn (scientific format);
"g" and "G" put x[i] into scientific format only if it saves
space to do so. "fg" uses fixed format as "f" , but digits as
number of significant digits. Note that this can lead to
quite long result strings. Default depends on the class of x . |
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.
Default is 2 . |
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 "" . |
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" (strong), "e" (emphasis), "m" (monospaced)
or "" (no markup).
Default 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 right).
The default value is "" . |
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" .
Default is "" . |
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).
Default is 1 . |
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 contain any of the AsciiDoc elements that are allowed inside document),
"l" (literal), "v" (verse; all line breaks are retained).
Default is "" . |
cgroup |
Character vector defining major column headings.
The default is to have none (NULL ). |
n.cgroup |
A numeric vector containing the number of columns for which each
element in cgroup is a heading. For example, specify
cgroup=c("Major 1","Major 2") , n.cgroup=c(3,3) if "Major
1" is to span columns 1-3 and "Major 2" is to span columns
4-6. Row names count in the column numbers if
include.rownames = TRUE . |
calign |
Character vector of length one defining alignment of major column headings. |
cvalign |
Character vector of length one defining vertical alignment of major column headings. |
cstyle |
Character vector of length one indicating the style of major column headings |
rgroup |
Character vector defining major 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 row headings. |
rvalign |
Character vector of length one defining vertical alignment of major row headings. |
rstyle |
Character vector of length one indicating the style of major row headings |
list.type |
Character vector of length one indicating the list
type ("bullet" , "number" , "label" or
"none" ). If "label" , names(list) is
used for labels. Default is "bullet" . |
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() ). |
... |
Additional arguments. (Currently ignored.) |
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")
.
This function returns an object of class c("ascii","proto","environment")
.
David Hajage dhajage@gmail.com
data(esoph) ascii(esoph[1:10,]) tab <- table(esoph$agegp, esoph$alcgp) ascii(tab) print(ascii(tab), type = "t2t") print(ascii(tab), type = "sphinx") print(ascii(tab), type = "org") ascii(summary(tab))