to_latex | R Documentation |
Use information from an R object to print a LaTeX table that mimics the
look of SPSS output. Typically, one would first call to_SPSS
with an object returned by a function in r2spss, and then call
to_latex
with the resulting object of class "SPSS_table"
to
print the LaTeX table. Note that the print
methods in r2spss
perform these two steps at once, but calling to_SPSS
and
to_latex
separately can be useful for customization of the LaTeX
table.
to_latex(object, ...) ## S3 method for class 'SPSS_table' to_latex(object, version = r2spss_options$get("version"), ...) ## S3 method for class 'data.frame' to_latex( object, main = NULL, sub = NULL, header = TRUE, label = NULL, row_names = TRUE, info = NULL, alignment = NULL, border = NULL, footnotes = NULL, major = NULL, minor = NULL, version = r2spss_options$get("version"), ... )
object |
an object of class |
... |
for the |
version |
a character string specifying whether the table should
mimic the look of recent SPSS versions ( |
main |
a single character string defining the main title of the SPSS
table, or |
sub |
a single character string defining the sub-title of the SPSS
table, or |
header |
a logical indicating whether to include a header in the SPSS
table based on the column names of
Line breaks (character |
label |
a character string giving a label to be added as the first
column of the table, or |
row_names |
a logical indicating whether to add the row names of
|
info |
an integer giving the number of columns in the SPSS table
that contain auxiliary information on the results. This has an effect
of the default formatting, alignment, and borders. The default is 0 if
|
alignment |
a list with components |
border |
a logical vector indicating which (outer and inner) vertical
borders should be drawn. The default is that tables that mimic recent
versions of SPSS ( |
footnotes |
a character vector giving footnotes to be added below the
SPSS table, or
|
major, minor |
an integer vector specifying the rows of the SPSS
table after which to draw major or minor grid lines that stretch across
all columns of the table, or
The only difference between the two type of grid lines is that minor grid
lines can also be suppressed globally within the current R session by
setting |
The "SPSS_table"
method takes component table
of the object
and supplies it to the data.frame
method, with additional components
in the object being passed as additional arguments.
The "data.frame"
method allows to extend the functionality of
r2spss with additional LaTeX tables that mimic the look of SPSS
output.
Nothing is returned, the function is called for its side effects.
LaTeX tables that mimic recent versions of SPSS (version = "modern"
)
may require several LaTeX compilations to be displayed correctly.
Andreas Alfons
## Kruskal-Wallis test example # load data data("Eredivisie") # compute a Kruskual-Wallis test to investigate whether # market values differ by playing position kw <- kruskal_test(Eredivisie, "MarketValue", group = "Position") # convert to an object of class "SPSS_table" that # contains the table with the test results kw_spss <- to_SPSS(kw, statistics = "test") kw_spss # blank out the number of degrees of freedom to ask # an assignment question about it kw_spss$table[2, 1] <- "???" # print the LaTeX table to be included in the assignment to_latex(kw_spss) ## t test example # load data data("Exams") # test whether the average grade on the resit # differs from 5.5 (minimum passing grade) t <- t_test(Exams, "Resit", mu = 5.5) # convert to an object of class "SPSS_table" that # contains the table with the test results t_spss <- to_SPSS(t, statistics = "test") # this is an example of a complex header layout t_spss$header # add additional line breaks in bottom-level header t_spss$header[[3]] <- gsub("-", "-\n", t_spss$header[[3]], fixed = TRUE) # print the LaTeX table to_latex(t_spss)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.