xtable.summary {papeR}R Documentation

Create And Print Tables With Markup

Description

The function produces objects which can be printed to LaTeX and HTML code.

Usage


## S3 method for class 'summary'
xtable(x, caption = NULL, label = NULL, align = NULL,
       digits = NULL, display = NULL, ...)

## S3 method for class 'xtable.summary'
print(x, rules = NULL, header = NULL,
      caption.placement = getOption("xtable.caption.placement", "top"),
      hline.after = getOption("xtable.hline.after", NULL),
      include.rownames = FALSE,
      add.to.row = getOption("xtable.add.to.row", NULL),
      booktabs = getOption("xtable.booktabs", TRUE),
      sanitize.text.function = get_option(x, "sanitize"),
      math.style.negative = getOption("xtable.math.style.negative", TRUE),
      math.style.exponents = getOption("xtable.math.style.exponents", TRUE),
      tabular.environment = getOption("xtable.tabular.environment", "tabular"),
      floating = getOption("xtable.floating", FALSE),
      latex.environments = getOption("xtable.latex.environments", c("center")),
      ...)

Arguments

x

object of class "summary", which is produced by the function summarize or an object of class "xtable.summary" produced by xtable.

caption

character vector specifying the table's caption; see xtable for details.

label

character string specifying the LaTeX label or HTML anchor; see xtable for details.

align

character string specifying the alignment of table columns; see xtable for details.

digits

numeric vector specifying the number of digits to display in each column; see xtable for details.

display

character string specifying the column types; see xtable for details.

rules

character string specifying the rules to be used. Per default the rules are defined by summarize and subsequently extracted from x via get_option(x, "rules").

header

character string specifying the table header to be used. Per default the header is defined by summarize and subsequently extracted from x via get_option(x, "header").

caption.placement

can be either "bottom" or "top" (default). Note that the standard default of print.xtable is "bottom".

hline.after

vector indicating the rows after which a horizontal line is printed. Here, the default is to not draw hlines (i.e. hline.after = NULL) and horizontal lines are added via add.to.row (see there for details). Note that the standard default of print.xtable is c(-1,0,nrow(x)).

add.to.row

list of row numbers (pos) and text (command) to be added to the specified rows. Per default, top and bottom rules are added to the table and a rule specified in rules is added below the heading. If sep = TRUE in summarize additional separators (as specified in rules) are added after each variable.

include.rownames

logical. Always set to FALSE.

booktabs

logical. If TRUE (default), the toprule, midrule and bottomrule tags from the LaTeX package "booktabs" are used rather than hline for the horizontal line tags. Note that the standard default of print.xtable is FALSE.

sanitize.text.function

All non-numeric enteries (except row and column names) are sanitised in an attempt to remove characters which have special meaning for the output format. Per default the function toLatex is used to sanitize the text. For more options see print.xtable.

math.style.negative

logical. If TRUE (default) the negative sign is wrapped in dollar signs for LaTeX tables. Note that the standard default of print.xtable is FALSE.

math.style.exponents

logical. If TRUE (default) scientific numers are set as exponents. See print.xtable for details. Note that the standard default of print.xtable is FALSE.

tabular.environment

character string. Per default "tabular" is used. For long tables that span over more than one page, one can use "longtable". For more options see print.xtable.

floating

logical. Determine if the table is printed in a floating environment. Note that the standard default of print.xtable is TRUE. See there for details.

latex.environments

character string. Per default "center" is used. In contrast to the default behavior of print.xtable, tables are also centered if no floating environment is used. For details and more options see print.xtable.

...

additional arguments passed to xtable or print.xtable. See there for details.

Details

We use the standard xtable function but add a special class that allows different defaults in the print.xtable function.

In general, all options of print.xtable can be used as well as global options set via options(). E.g. options(xtable.booktabs = FALSE will set the argument booktabs per default to FALSE for all calls to print.xtable.

Value

After printing, a table with LaTeX markup is returned.

Author(s)

Benjamin Hofner

See Also

For details see xtable and print.xtable.

summarize, get_option

Examples

if (require("nlme")) {
    ## Use dataset Orthodont
    data(Orthodont, package = "nlme")

    ## Get summary for continuous variables
    (tab1 <- summarize(Orthodont, type = "numeric"))

    ## Get summary for categorical variables
    (tab2 <- summarize(Orthodont, type = "fac"))

    ## Using the tables with LaTeX
    if (require("xtable")) {
        xtable(tab1)
        ## grouped table
        xtable(summarize(Orthodont, group = "Sex"))
        xtable(tab2)
    }
}

[Package papeR version 1.0-5 Index]