Description Usage Arguments Details Value Author(s) References See Also Examples
The functions tabular
, as.document
, and as.pdf
are generic. Methods are given here that cascade in the order data.frame -> tabular (character)
-> document -> pdf. as.document.data.frame
is argued identically to tabular
,
except for a few extra arguments; the function tries to guess the exact length and
width for a page size identical to the printed area (you can modify with the arguments
wider
and longer
). as.pdf.document
needs a file stem and
(optionally) whether to perform clean-up. The other as.pdf
methods are
convenience wrappers. as.tabular
is an alias for tabular
. See also
ltable
, which wraps tabular output in a table environment.
tex2pdf
accepts the file names of tex fragments. It reads those fragments,
wraps them like documents and makes pdf files. viewtex
goes one step further,
and tries to open those pdfs for viewing.
tabular.table
reclassifies its argument as matrix. tabular.matrix
converts
its argument to data.frame. If the rownames are suitably named, they are adopted as a
column in the first position.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | ## S3 method for class 'data.frame'
tabular(
x,
rules = c(2, 1, 1),
walls = 0,
grid = FALSE,
rowgroups = factor(rownames(x)),
colgroups = factor(names(x)),
rowbreaks = if (grid) breaks(rowgroups, ...) else 0,
colbreaks = if (grid) breaks(colgroups, ...) else 0,
rowgrouprule = 0,
colgrouprule = 0,
rowcolors=NULL,
rowgrouplabel=' ',
charjust = "left",
numjust = "right",
justify = ifelse(sapply(x, is.numeric), numjust, charjust),
colwidth = NA,
paralign = "top",
na = "",
verbatim = ifelse(sapply(x, is.numeric), TRUE, FALSE),
escape = "#",
trim = TRUE,
source=NULL,
file=NULL,
source.label='source: ',
file.label='file: ',
basefile=FALSE,
tabularEnvironment='tabular',
footnote.size = 'tiny',
...
)
## S3 method for class 'define'
tabular(
x,
caption = '',
grid = TRUE,
rules = 1,
colwidth = c('1in','1in','0.5in','1.5in','1.5in'),
tabularEnvironment = 'longtable',
walls = 1,
tabnum = FALSE,
pretable = if(is.null(caption)) '' else
paste( if(tabnum) '\\caption{' else
'\\caption*{',caption,'}\\\\'),
prepos = 1,
headerBold = TRUE,
...
)
## S3 method for class 'matrix'
tabular(x, ...)
## S3 method for class 'table'
tabular(x, ...)
## S3 method for class 'data.frame'
as.document(
x,
rules = c(2, 1, 1),
walls = 0,
grid = FALSE,
rowgroups = factor(rownames(x)),
colgroups = factor(names(x)),
rowbreaks = if (grid) breaks(rowgroups, ...) else 0,
colbreaks = if (grid) breaks(colgroups, ...) else 0,
rowcolors=NULL,
charjust = "left",
numjust = "right",
justify = ifelse(sapply(x, is.numeric), numjust, charjust),
colwidth = NA,
paralign = "top",
na = "",
verbatim = ifelse(sapply(x, is.numeric), TRUE, FALSE),
escape = "#",
trim = TRUE,
wider=0,
longer=0,
...
)
## S3 method for class 'character'
as.document(
x,
preamble=makePreamble(...),
thispagestyle=command('thispagestyle',args='empty'),
pagestyle=command('pagestyle',args='empty'),
prolog=NULL,
epilog=NULL,
...
)
## S3 method for class 'define'
as.document(
x,
morePreamble = command('usepackage',args = 'longtable'),
geoLeft = '1in',
geoRight = '1in',
geoTop = '1in',
geoBottom = '1in',
pagestyle = command("pagestyle", args = "plain"),
...
)
## S3 method for class 'document'
as.pdf(x,stem,dir='.',clean=TRUE,...)
## S3 method for class 'character'
as.pdf(x,stem,...)
## S3 method for class 'data.frame'
as.pdf(x,stem,...)
## S3 method for class 'define'
as.pdf(x,stem,...)
makePreamble(
landscape=FALSE,
wide=if(landscape) 279.4 else 215.9,
long=if(landscape) 215.9 else 279.4,
geoLeft = '1mm',
geoRight = '1mm',
geoTop = '1mm',
geoBottom = '1mm',
documentclass = command('documentclass',args='article'),
xcolorPackage = command('usepackage',options=list('usenames',
'dvispnames','svgnames','table'),args='xcolor'),
geometryPackage = command(
'usepackage',
options=list(
left=geoLeft,
top=geoTop,
bottom=geoBottom,
right=geoRight
),
args='geometry'
),
geometry = command(
'geometry',
args=list(
glue(
'papersize=',
glue('{',wide,'mm',',',long,'mm}')
)
)
),
multirow = command('usepackage',args='multirow'),
morePreamble = NULL,
...
)
tex2pdf(
x,
stem=NULL,
dir=NULL,
clean=TRUE,
onefile=FALSE,
...
)
viewtex(x,delete=TRUE,latency=1,...)
|
x |
object to be converted, typically data.frame (paths of tex files for |
rules |
numeric; will be recycled to length 3. indicates number of horizontal lines above and below the header, and below the last row. |
walls |
numeric, recycled to length 2. Number of vertical lines on left and right of table. |
grid |
logical, whether to have lines between rows and columns |
rowgroups |
a vector as long as nrow(x), non-repeats trigger horizontal lines |
colgroups |
a vector as long as names(x), non-repeats trigger vertical lines |
rowbreaks |
numeric: a manual way to specify numbers of lines between rows (ignores grid and rowgroups) |
colbreaks |
numeric: a manual way to specify numbers of lines between columns (ignores grid and colgroups) |
rowgrouprule |
number of lines to set off row group column, if rowgroups supplied as character |
colgrouprule |
number of lines to set off col group header, if colgroups supplied as character |
rowcolors |
character vector of color names, recycled as necessary to color all rows (NULL: no color) |
rowgrouplabel |
character string (at least one character) to label rowgroup column |
charjust |
default justification for character columns |
numjust |
default justification for numeric columns |
justify |
manual specification of column justifications: left, right, center, or decimal (vector as long as ncol(x)) |
colwidth |
manual specification of column width. (vector of length ncol(x).) Overrides |
paralign |
used with colwidth to align paragraphs: top, middle, or bottom. |
na |
string to replace NA elements |
verbatim |
whether to use verbatim environment for numeric fields. Makes sense for decimal justification; interacts with |
escape |
symbol used by ‘verb’ command as delimiter. A warning is issued if it is found in non-NA text. |
trim |
passed to the format command: true by default, so that alignment is the responsibility of just the tabular environment arguments |
source |
optional source attribution |
file |
optional file name |
source.label |
optional text to preceed source if specified |
file.label |
optional text to preceed file if specified |
basefile |
if TRUE, strip path from file for display purposes |
tabularEnvironment |
default |
caption |
for |
tabnum |
for |
pretable |
for |
prepos |
for |
headerBold |
for |
wide |
document width in mm |
long |
document lenth in mm |
wider |
additional document width in mm |
longer |
additional document lenth in mm |
preamble |
latex markup to include before beginning the document |
landscape |
if TRUE, default orientation is ‘landscape’ not ‘portrait’ |
geoLeft |
geometry package: left margin |
geoRight |
geometry package: right margin |
geoTop |
geometry package: top margin |
geoBottom |
geometry package: bottom margin |
documentclass |
document class command |
xcolorPackage |
xcolor package command |
geometryPackage |
geometry package command |
geometry |
geometry specification |
multirow |
multirow specification |
morePreamble |
additional preamble before beginning the document |
thispagestyle |
thispagestyle command |
pagestyle |
pagestyle command |
prolog |
latex markup to include before x |
epilog |
latex markup to include after x |
stem |
the stem of a file name (no extension) |
dir |
output directory |
clean |
whether to delete system files after pdf creation |
onefile |
whether to combine tex snippets into a single file |
delete |
whether temporary pdf (_doc.pdf) should persist |
latency |
how many seconds to wait before deleting temporary pdf |
footnote.size |
font size for source and file attributions |
... |
passed to called functions |
Principal choices in tabular.data.frame
are the number of lines above and below the header,
number of lines at the end of the table (rules), and whether to have
lines between rows and columns (grid). If you do want the latter, you
can modify their placement easily with rowgroups and colgroups: factor-like
objects that show implicitly which sets of columns or rows go together. Neighboring
groups will be separated with a line. For multiple lines at a given
position, explicit control is offered by rowbreaks and colbreaks. These
latter have lengths one less than their respective dimensions.
As of v5.56, if you specify rowgroups or colgroups as a character vector, the
appropriate margin will be explicitly subclassified (extra column for rowgroups
and extra header for colgroups). If you also supply non-default column attributes
(e.g. colbreaks, na, verbatim, colwidth, justify), add an extra element for the rowgroup column
to overide internal defaults. Row color (rowcolors) seems not to be
entirely compatible with multirow cells (explicit rowgroups). For rowgroups,
be sure to use package multirow
in your latex preamble.
If source
and source.label
are defined, they will be printed in a footnote.size
font immediately
under the table (bound to the tabular element). If file
and file.label
are defined as well,
they will be printed (same size) under source. Set source.label
to NULL to
suppress embedding of source
; set to empty string to suppress source label. Set file.label
to NULL to
suppress embedding of file
; set to empty string to suppress file label. Note that
file
controls file destination, whether or not represented in the result.
Rownames are ignored. If informative, capture them as a column (done implicitly
for tabular.table
and tabular.matrix
).
Converting a tabular
object or any character vector to a document causes
inclusion of default values for the the arguments of makePreamble
and
as.document.character
. Any of these can be dropped by passing NULL. Invocation
of makePreamble
can be avoided entirely by passing a value for preamble
.
Alternatively, specify morePreamble
to extend the preamble, or to replace any elements
you may have dropped.
character
Tim Bergsma
http://metrumrg.googlecode.com
ltable
align.decimal
breaks
row2tabular
tabularformat
wrap
as.define
1 2 3 4 5 6 7 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.