#' Test for significant difference between 2 vectors
#' @param x First data vector
#' @param y Second data vector
#' This function tests if the distributions of the 2 vectors follow normality
#' and performs t-test for normal data
#' Wilcox test for non-normal data
#' @export
pvalue <- function(x, y){
testx <- shapiro.test(x)
testy <- shapiro.test(y)
print(testx$p.value)
print(testy$p.value)
if( testx$p.value > 0.05 & testy$p.value > 0.05) {
# print("t-test")
out <- t.test(x, y)
} else {
# print("wilcox test")
out <- wilcox.test(x, y)
}
print(out$p.value)
out$p.value
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.