Learn R Programming

r2spss (version 0.3.2)

descriptives: Descriptive Statistics

Description

Compute descriptive statistics of numeric variables of a data set (number of observations, minimum, maximum, mean, standard deviaiton). The output is printed as a LaTeX table that mimics the look of SPSS output.

Usage

descriptives(data, variables)

# S3 method for descriptives_SPSS to_SPSS(object, digits = 2, ...)

# S3 method for descriptives_SPSS print(x, version = r2spss_options$get("version"), ...)

Arguments

data

a data frame containing the variables.

variables

a character vector specifying numeric variables for which to compute descriptive statistics.

object, x

an object of class "descriptives_SPSS" as returned by function descriptives.

digits

an integer giving the number of digits after the comma to be printed in the SPSS table.

additional arguments to be passed down to format_SPSS.

version

a character string specifying whether the table should mimic the look of recent SPSS versions ("modern") or older versions (<24; "legacy").

Value

An object of class "descriptives_SPSS" with the following components:

classes

a character vector giving the (first) class of the variables of interest.

descriptives

a data frame containing the descriptive statistics.

n

an integer giving the number of observations.

The to_SPSS method returns an object of class "SPSS_table" which contains all relevant information in the required format to produce the LaTeX table. See to_latex for possible components and how to further customize the LaTeX table based on the returned object.

The print method produces a LaTeX table that mimics the look of SPSS output.

Details

The print method first calls the to_SPSS method followed by to_latex. Further customization can be done by calling those two functions separately, and modifying the object returned by to_SPSS.

Examples

Run this code
# NOT RUN {
# load data
data("Eredivisie")

# compute descriptive statistics for market value and age
descriptives(Eredivisie, c("MarketValue", "Age"))

# }

Run the code above in your browser using DataLab