spsspivottable.Display Function (R)
The spsspivottable.Display
function provides the ability to render tabular output from R as
a pivot table that can be displayed in the IBM® SPSS® Statistics Viewer or written to an external
file using the IBM SPSS Statistics Output Management
System.
- By default, the name that appears in the outline
pane of the Viewer associated with the pivot table is R. You can customize the name and nest multiple
pivot tables under a common heading by wrapping the pivot table generation
in a
StartProcedure-EndProcedure
block. See the topic spsspkg.StartProcedure Function (R) for more information. - The
spsspivottable.Display
function is limited to pivot tables with one row dimension and one column dimension. To create more complex pivot tables, use the BasePivotTable class.
spsspivottable.Display(x,title,templateName,outline,caption,isSplit,rowdim,coldim,hiderowdimtitle, hiderowdimlabel,hidecoldimtitle,hidecoldimlabel,rowlabels,collabels,format). Creates a pivot table with one row dimension and one column dimension. All arguments other than x are optional.
- x. The data to be displayed as a pivot table. It may be a data frame, matrix, table, or any R object that can be converted to a data frame.
- title. A character string that specifies the title that appears with the table. The default is "Rtable".
-
templateName. A character string that specifies the OMS (Output Management System)
table subtype for this table. It must begin with a letter and have
a maximum of 64 bytes. The default is "Rtable". Unless you are routing
this pivot table with OMS and need to distinguish subtypes you do
not need to specify a value.
When routing pivot table output from R using OMS, the command name associated with this output is
R
by default, as inCOMMANDS=['R']
for theCOMMANDS
keyword on theOMS
command. If you wrap the pivot table output in aStartProcedure-EndProcedure
block, then use the name specified in theStartProcedure
call as the command name. See the topic spsspkg.StartProcedure Function (R) for more information. - outline. A character string that specifies a title, for the pivot table, that appears in the outline pane of the Viewer. The item for the table itself will be placed one level deeper than the item for the outline title. If omitted, the Viewer item for the table will be placed one level deeper than the root item for the output containing the table.
- caption. A character string that specifies a table caption.
-
isSplit. A
logical value (TRUE or FALSE) specifying whether to enable split
file processing for the table. The default is TRUE. Split file processing refers to whether results
from different split groups are displayed in separate tables or in
the same table but grouped by split, and is controlled by the
SPLIT FILE
command.When retrieving data with
spssdata.GetSplitDataFromSPSS
, callspsspivottable.Display
with the results for each split group. The results from each split group are accumulated and the subsequent table(s) are displayed whenspssdata.CloseDataConnection
is called. - rowdim. A character string specifying a title for the row dimension. The default is "row".
- coldim. A character string specifying a title for the column dimension. The default is "column".
- hiderowdimtitle. A logical value (TRUE or FALSE) specifying whether to hide the row dimension title. The default is TRUE.
- hiderowdimlabel. A logical value specifying whether to hide the row labels. The default is FALSE.
- hidecoldimtitle. A logical value specifying whether to hide the column dimension title. The default is TRUE.
- hidecoldimlabel. A logical value specifying whether to hide the column labels. The default is FALSE.
- rowlabels. A numeric or character vector specifying the row labels. If provided, the length of the vector must equal the number of rows in the argument x. If omitted, the row names of x will be used. If x does not have row names, the labels "row1", "row2", etc., will be used. If a numeric vector is provided, the row labels will have the format specified by the argument format.
- collabels. A numeric or character vector specifying the column labels. If provided, the length of the vector must equal the number of columns in the argument x. If omitted, the column names of x will be used. If x does not have column names, the labels "col1", "col2", etc., will be used. If a numeric vector is provided, the column labels will have the format specified by the argument format.
-
format. Specifies
the format to be used for displaying numeric values, including cell
values, row labels, and column labels. The argument format is of the form
formatSpec.format
whereformat
is one of those listed in the table below--for example,formatSpec.Correlation
. You can also specify an integer code for format, as in the value3
forCorrelation
. The default format isGeneralStat
.
Example
BEGIN PROGRAM R.
demo <- data.frame(A=c("1A","2A"),B=c("1B","2B"),row.names=c(1,2))
spsspivottable.Display(demo,
title="Sample Pivot Table",
rowdim="Row",
hiderowdimtitle=FALSE,
coldim="Column",
hidecoldimtitle=FALSE)
END PROGRAM.
Result

Format name | Code |
---|---|
Coefficient | 0 |
CoefficientSE | 1 |
CoefficientVar | 2 |
Correlation | 3 |
GeneralStat | 4 |
Count | 6 |
Percent | 7 |
PercentNoSign | 8 |
Proportion | 9 |
Significance | 10 |
Residual | 11 |
Suggestions for Choosing a Format
- Consider using
Coefficient
for unbounded, unstandardized statistics; for instance, beta coefficients in regression. -
Correlation
is appropriate for statistics bounded by –1 and 1 (typically correlations or measures of association). - Consider using
GeneralStat
for unbounded, scale-free statistics; for instance, beta coefficients in regression. -
Count
is appropriate for counts and other integers such as integer degrees of freedom. -
Percent
andPercentNoSign
are both appropriate for percentages.PercentNoSign
results in a value without a percentage symbol (%). -
Significance
is appropriate for statistics bounded by 0 and 1 (for example, significance levels). - Consider using
Residual
for residuals from cell counts.