xtable.xbal: An 'xtable' method for 'xbal' objects

Description Usage Arguments Details Value Examples

View source: R/xtable.xbal.R

Description

This function uses the xtable package framework to display the results of a call to balanceTest in LaTeX format. At the moment, it ignores the omnibus chi-squared test information.

Usage

1
2
3
4
## S3 method for class 'xbal'
xtable(x, caption = NULL, label = NULL, align = c("l",
  rep("r", ncol(xvardf))), digits = 2, display = NULL, col.labels = NULL,
  ...)

Arguments

x

An object resulting from a call to balanceTest.

caption

See xtable.

label

See xtable.

align

See xtable. Our default (as of version 0.1-7) is right-aligned columns; for decimal aligned columns, see details, below.

digits

See xtable. Default is 2.

display

See xtable.

col.labels

Labels for the columns (the test statistics). Default are come from the call to print.xbal.

...

Other arguments to print.xbal.

Details

The resulting LaTeX will present one row for each variable in the formula originally passed to balanceTest, using the variable name used in the original formula. If you wish to have reader friendly labels instead of the original variables names, see the code examples below.

To get decimal aligned columns, specify align=c("l", rep(".", <ncols>)), where <ncols> is the number of columns to be printed, in your call to xtable. Then use the dcolumn package and define '.' within LaTeX: add the lines \usepackage{dcolumn} and \newcolumntype{.}{D{.}{.}{2.2}} to your LaTeX document's preamble.

Value

This function produces an xtable object which can then be printed with the appropriate print method (see print.xtable).

Examples

 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
data(nuclearplants)
require(xtable)

# Test balance on a variety of variables, with the 'pr' factor
# indicating which sites are control and treatment units, with
# stratification by the 'pt' factor to group similar sites
xb1 <- balanceTest(pr ~ date + t1 + t2 + cap + ne + ct + bw + cum.n + strata(pt),
                data = nuclearplants,
                report = c('adj.means', 'adj.mean.diffs',
                           'std.diffs', 'z.scores',
                           'chisquare.test', 'p.values'))

xb1.xtab <- xtable(xb1) # This table has right aligned columns

# Add user friendly names in the final table
rownames(xb1.xtab) <- c("Date", "Application to Contruction Time",
"License to Construction Time", "Net Capacity", "Northeast Region", "Cooling Tower",
"Babcock-Wilcox Steam", "Cumlative Plants", "(Element Weight)")

print(xb1.xtab,
      add.to.row = attr(xb1.xtab, "latex.add.to.row"),
      hline.after = c(0, nrow(xb1.xtab)),
      sanitize.text.function = function(x){x},
      floating = TRUE,
      floating.environment = "sidewaystable")

markmfredrickson/RItools documentation built on Oct. 3, 2018, 1:07 p.m.