Here is a simple randomized experiment.
In the following code I calculate the p-value under the null hypothesis that two different fertilizers applied to tomato plants have no effect in plants yields. The first random sample (x) comes from plants where a standard fertilizer has been used, while an "improved" one has been used in the plants where the second sample (y) comes from.
x <- c(11.4,25.3,29.9,16.5,21.1)
y <- c(23.7,26.6,28.5,14.2,17.9,24.3)
total <- c(x,y)
first <- combn(total,length(x))
second <- apply(first,2,function(z) total[is.na(pmatch(total,z))])
dif.treat <- apply(second,2,mean) - apply(first,2,mean)
# the first element of dif.treat is the one that I'm interested in
(p.value <- length(dif.treat[dif.treat >= dif.treat[1]]) / length(dif.treat))
Do you know of any R function that performs tests like this one?
EDIT
# this is the equivalent independent t.test
t.test(x,y,alternative = "less",var.equal = T)