# \donttest{
# Group1 normal, Group 2 right skewed with equal means and different variances
set.seed(1199)
grp1 <- rnorm(20, 45, 5)
grp2 <- c(rnorm(10, 45, 10), rnorm(10, 52, 20))
df <- data.frame(cbind(grp1=grp1, grp2=grp2))
head(df)
bivarplot(df)
# Reshape the data into long format
df <- wide2long(df)
head(df)
# Differences between the basic stats
calcstatdif(df)
# Permutation test for the differences between the basic stats of two groups
result <- permtest(df, statistic = calcstatdif, alternative = "two.sided", R = 500)
result$pval
# Permutation with custom statistics
# A custom function to compute the differences between the group means
meancomp <- function(x, ...){
meandif <- diff(rev(tapply(x[,1], x[,2], mean)))
return(meandif)
}
# Permutation test with meancomp function
result <- permtest(x = df, statistic = meancomp, alternative="less", R=500)
result$pval
# }
Run the code above in your browser using DataLab