xtable.xbal | R Documentation |
xtable
method for xbal
and balancetest
objectsThis 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.
## S3 method for class 'xbal'
xtable(
x,
caption = NULL,
label = NULL,
align = c("l", rep("r", ncol(xvardf))),
digits = 2,
display = NULL,
auto = FALSE,
col.labels = NULL,
...
)
x |
An object resulting from a call to
|
caption |
See |
label |
See |
align |
See |
digits |
See |
display |
See |
auto |
See |
col.labels |
Labels for the columns (the test
statistics). Default are come from the call to
|
... |
Other arguments to |
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.
This function produces an xtable
object which can
then be printed with the appropriate print
method (see
print.xtable
).
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)
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")
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.