I have a data frame which looks like this. There are 2 separate groups and 5 different variables.
df <- read.table(text="Group var1 var2 var3 var4 var5
1 3 5 7 3 7
1 3 7 5 9 6
1 5 2 6 7 6
1 9 5 7 0 8
1 2 4 5 7 8
1 2 3 1 6 4
2 4 2 7 6 5
2 0 8 3 7 5
2 1 2 3 5 9
2 1 5 3 8 0
2 2 6 9 0 7
2 3 6 7 8 8
2 10 6 3 8 0", header = TRUE)
I'm calculating the significance of each variable for distinguishing between the 2 groups using the T test (as below). However I'd like to implement permutation testing to calculate the p values as this is quite a small dataset. What is the best method for doing this in R?
t(sapply(df[-1], function(x)
unlist(t.test(x~df$Group)[c("p.value")])))