oneSampleTTest: One sample t-test

Description Usage Arguments Details Value See Also Examples

View source: R/oneSampleTTest.R

Description

Convenience function that runs a one sample t-test. This is a wrapper function intended to be used for pedagogical purposes only.

Usage

1
oneSampleTTest(x, mu, one.sided = FALSE, conf.level = 0.95)

Arguments

x

The variable to be tested (required).

mu

The value against which the mean should be tested (required).

one.sided

One sided or two sided hypothesis test (default = FALSE)

conf.level

The confidence level for the confidence interval (default = .95).

Details

The oneSampleTTest function runs a one-sample t-test on the data in x, and prints the results in a format that is easier for novices to handle than the output of t.test. All the actual calculations are done by the t.test and cohensD functions.

As with the t.test function, the default test is two sided, corresponding to a default value of one.sided = FALSE. To specify a one sided test in which the alternative hypothesis is that x is larger than mu, the input must be one.sided = "greater". Similarly, if one.sided="less", then the alternative hypothesis is that the mean of x is smaller than mu.

Value

An object of class 'TTest'. When printed, the output is organised into five short sections. The first section lists the name of the test and the variables included. The second provides means and standard deviations. The third states explicitly what the null and alternative hypotheses were. The fourth contains the test results: t-statistic, degrees of freedom and p-value. The final section includes the relevant confidence interval and an estimate of the effect size (i.e., Cohen's d).

See Also

t.test, pairedSamplesTTest, independentSamplesTTest, cohensD

Examples

1
2
3
4
5
6
7
8
likert <- c(3,1,4,1,4,6,7,2,6,6,7)

oneSampleTTest( x = likert, mu = 4 )
oneSampleTTest( x = likert, mu = 4, one.sided = "greater" )
oneSampleTTest( x = likert, mu = 4, conf.level=.99 )

likert <- c(3,NA,4,NA,4,6,7,NA,6,6,7)
oneSampleTTest( x = likert, mu = 4 )

lsr documentation built on Dec. 11, 2021, 9:10 a.m.