tTest: t Tests

Description Usage Arguments Value Author(s) Examples

View source: R/tTest.R

Description

Perform a one-sample t test, a paired-sample t test or an independent-samples t test on variables of a data set. The output is printed as a LaTeX table that mimics the look of SPSS output (version <24).

Usage

1
2
3
4
tTest(data, variables, group = NULL, mu = 0, conf.level = 0.95)

## S3 method for class 'tTestSPSS'
print(x, digits = 3, statistics = c("statistics", "test"), ...)

Arguments

data

a data frame containing the variables.

variables

a character vector specifying numeric variable(s) to be used for testing the mean(s). If group is NULL, a one-sample t test is performed if only one variable is specified, and a paired-sample t test is performed if two variables are specified. If a grouping variable is specified in group, an independent-samples t-test is performed and this should be a character string specifying the numeric variable of interest.

group

a character string specifying a grouping variable for an independent-samples t-test, or NULL.

mu

a number indicating the true value of the mean for a one-sample t test.

conf.level

a number between 0 and 1 giving the confidence level of the confidence interval.

x

an object of class "tTestSPSS" as returned by function tTest.

digits

an integer giving the number of digits after the comma to be printed in the LaTeX tables.

statistics

a character vector specifying which LaTeX tables should be printed. Available options are "statistics" for descriptive statistics and "test" for test results. The default is to print both tables.

...

currently ignored.

Value

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

statistics

a data frame containing the relevant descriptive statistics.

test

an object of class "htest" as returned by t.test (only one-sample and paired-sample tests).

variables

a character vector containing the name(s) of the relevant numeric variable(s).

n

an integer giving the number of observations (only paired-sample test).

levene

an object as returned by leveneTest (only independent-samples test).

pooled

an object of class "htest" as returned by t.test assuming equal variances (only independent-samples test).

satterthwaite

an object of class "htest" as returned by t.test not assuming equal variance (only independent-samples test).

group

a character string containing the name of the grouping variable (only independent-samples test).

type

a character string giving the type of t test performed ("one-sample", "paired", or "independent").

The print method produces a LaTeX table that mimics the look of SPSS output (version <24).

Author(s)

Andreas Alfons

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## one-sample and paired-sample t test

# load data
data("Exams")

# test whether the average grade on the resit
# differs from 5.5 (minimum passing grade)
tTest(Exams, "Resit", mu = 5.5)

# test whether average grades differ between the
# regular exam and the resit
tTest(Exams, c("Resit", "Regular"))


## independent-samples t test

# load data
data("Eredivisie")
# log-transform market values
Eredivisie$logMarketValue <- log(Eredivisie$MarketValue)

# test whether average log market values differ between
# Dutch and foreign players
tTest(Eredivisie, "logMarketValue", group = "Foreign")

r2spss documentation built on Nov. 25, 2021, 1:06 a.m.