CellText.Number Class (R)
spss.CellText.Number(value,formatspec,varIndex). Used to specify a numeric value for a
category or a cell in a pivot table. The argument value specifies the numeric value. You can
pass an R POSIXt date/time object to this argument. The optional argument formatspec is of the form formatSpec.format
where format
is one of those listed in the table
below--for example, formatSpec.Mean
. You can also specify an integer code for formatspec, as in the value 5
for Mean
. The
argument varIndex is the index
of a variable in the active dataset whose format is used to determine
details of the resulting format. varIndex is only used in conjunction with formatspec and is required when specifying one of the following formats: Mean
, Variable
, StdDev
, Difference
, and Sum
. Index values represent position in the active dataset, starting
with 0 for the first variable in file order.
- When formatspec is omitted, the default format is used. You can set the default
format with the SetDefaultFormatSpec method
and retrieve the default with the GetDefaultFormatSpec method.
Instances of the
BasePivotTable
class have an implicit default format ofGeneralStat
. - You can obtain a numeric representation of a
CellText.Number
object using the toNumber method, and you can use the toString method to obtain a string representation.
Example
table = spss.BasePivotTable("Table Title",
"OMS table subtype")
rowdim=BasePivotTable.Append(table,Dimension.Place.row,"rowdim")
coldim=BasePivotTable.Append(table,Dimension.Place.column,"coldim")
row_cat1 = spss.CellText.String("row1")
row_cat2 = spss.CellText.String("row2")
col_cat = spss.CellText.String("col1")
BasePivotTable.SetCategories(table,rowdim,list(row_cat1,row_cat2))
BasePivotTable.SetCategories(table,coldim,col_cat)
BasePivotTable.SetCellValue(table,list(row_cat1,col_cat),
spss.CellText.Number(25.632,formatSpec.Mean,2))
BasePivotTable.SetCellValue(table,list(row_cat2,col_cat),
spss.CellText.Number(23.785,formatSpec.Mean,2))
In this example, cell values are displayed in the format used for mean values. The format of the variable with index 2 in the active dataset is used to determine the details of the resulting format.
Format name | Code |
---|---|
Coefficient | 0 |
CoefficientSE | 1 |
CoefficientVar | 2 |
Correlation | 3 |
GeneralStat | 4 |
Mean | 5 |
Count | 6 |
Percent | 7 |
PercentNoSign | 8 |
Proportion | 9 |
Significance | 10 |
Residual | 11 |
Variable | 12 |
StdDev | 13 |
Difference | 14 |
Sum | 15 |
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. -
Mean
is appropriate for the mean of a single variable, or the mean across multiple variables. -
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. -
Variable
refers to a variable’s print format as given in the data dictionary and is appropriate for statistics whose values are taken directly from the observed data (for instance, minimum, maximum, and mode). -
StdDev
is appropriate for the standard deviation of a single variable, or the standard deviation across multiple variables. -
Sum
is appropriate for sums of single variables. Results are displayed using the specified variable’s print format.