Learn R Programming

r2spss (version 0.3.2)

format_SPSS: 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, ...)

# S3 method for default format_SPSS(object, ...)

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

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

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

# S3 method for 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.

Examples

Run this code
# NOT RUN {
# 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))

# }

Run the code above in your browser using DataLab