to_SPSS: Convert R Objects to SPSS-Style Tables

View source: R/to_SPSS.R

to_SPSSR Documentation

Convert R Objects to SPSS-Style Tables


Generic function to convert an R object into an object that contains all necessary information for printing a LaTeX table that mimics the look of SPSS output.


to_SPSS(object, ...)

to_spss(object, ...)



an R object for which a to_SPSS method exists, such as objects returned by functions in r2spss.


additional arguments passed down to methods.


In order to work as expected, methods of to_SPSS should return an object of class "SPSS_table". It should include a component table that contains a data frame, which can be supplied as the first argument to to_latex to print a LaTeX table that mimics the look of SPSS output. Additional components of the returned object define additional arguments to be passed to the "data.frame" method of to_latex.


to_spss is a simple wrapper for to_SPSS, which exists for convenience.


Andreas Alfons


# load data

# 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")

# 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

r2spss documentation built on May 25, 2022, 5:05 p.m.