27 lines
659 B
R
27 lines
659 B
R
t.test_single <- function(x, m, alternative = "two.sided") {
|
|
M <- mean(x)
|
|
n <- length(x)
|
|
statistic <- ((M - m) / sd(x)) * sqrt(n)
|
|
|
|
p <- if (alternative == "two.sided") {
|
|
2 * pt(q=abs(statistic), df=length(x)-1, lower.tail=FALSE)
|
|
} else if (alternative == "less") {
|
|
pt(q=statistic, df=length(x)-1, lower.tail = TRUE)
|
|
} else {
|
|
pt(q=statistic, df=length(x)-1, lower.tail = FALSE)
|
|
}
|
|
|
|
value <- list(mean = M, m = m, statistic = statistic, p.value = p, alternative = alternative)
|
|
return(value)
|
|
}
|
|
|
|
|
|
load("Hamulce.RData")
|
|
attach(Hamulce)
|
|
t.test(Wynik,mu=18.6,alternative='less')
|
|
t.test_single(Wynik, m=18.6, alternative='less')
|
|
|
|
|
|
|
|
|