my_t.test: T test function

Description Usage Arguments Value Examples

View source: R/my_t.test.R

Description

This function runs a t test on a vector of numbers.

Usage

1
my_t.test(x, alternative, mu)

Arguments

x

Numeric vector input of data to be subjected to a t test by my_t.test.

alternative

Character string input specifying the alternative hypothesis for my_t.test is being run. This should only accept "two.sided", "less", or "greater". Otherwise, your function should throw an informative error.

mu

Numeric input indicating the null hypothesis of the mean that my_t.test will compare the mean to.

Value

List with elements: "test_stat": the numeric test statistic. "df": the degrees of freedom. "alternative": the value of the parameter alternative. "p_val": the numeric p-value.

Examples

1
2
3
4
5
6
7
8
9
x <- as.vector(subset(data.frame(my_gapminder), select = c("lifeExp")))
alternative <- c("two.sided", "less", "greater")
mu <- 60

my_t.test(x, alternative = "two.sided", mu)

my_t.test(x, alternative = "less", mu)

my_t.test(x, alternative = "greater", mu)

anna-vasyura/STAT302package documentation built on Dec. 19, 2021, 3:39 a.m.