format_SPSS: Format Objects

View source: R/format_SPSS.R

format_SPSSR Documentation

Format Objects

Description

Format an object for printing, mostly used to print numeric data in the same way as SPSS. This is mainly for internal use in to_SPSS and print methods.

Usage

format_SPSS(object, ...)

## Default S3 method:
format_SPSS(object, ...)

## S3 method for class 'integer'
format_SPSS(object, ...)

## S3 method for class 'numeric'
format_SPSS(object, digits = 3, p_value = FALSE, check_int = FALSE, ...)

## S3 method for class 'matrix'
format_SPSS(object, digits = 3, p_value = FALSE, check_int = FALSE, ...)

## S3 method for class 'data.frame'
format_SPSS(object, digits = 3, p_value = FALSE, check_int = FALSE, ...)

formatSPSS(object, ...)

Arguments

object

an R object. Currently methods are implemented for vectors, matrices, and data frames. The default method calls as.character.

...

additional arguments passed down to methods.

digits

an integer giving the number of digits after the comma to display.

p_value

a logical indicating whether small positive values should be indicated as below the threshold defined by digits, e.g., "<.001" if digits = 3. This is used for formatting p-values in LaTeX tables that mimic the look of SPSS. For the "numeric" method, a logical vector indicates the behavior for each element of object. For the "matrix" or "data.frame" methods, a logical vector indicates the behavior for each column of object.

check_int

a logical indicating whether to check for integer values and format them as such, e.g., to format the integer 2 as "2" instead of "2.000" if digits = 3. For the "numeric" method, a logical vector indicates the behavior for each element of object. For the "matrix" or "data.frame" methods, a logical vector indicates the behavior for each column of object.

Value

A character vector, matrix, or data frame containing the formatted object.

Author(s)

Andreas Alfons

Examples

# note how numbers in the interval (-1, 1) are printed
# without the zero in front of the comma
format_SPSS(c(-1.5, -2/3, 2/3, 1.5))


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