You are on the right track.
Example (I added another value to suppress warnings about “set probabilities numerically 0 or 1”)
ex <- read.table(textConnection(
"ID group score
A1 1 3.5
A2 1 3.2
A3 0 2.8
A4 0 2.5
A5 1 2.4"),header=TRUE)
g0 <- glm(group~score,data=ex,family=binomial)
p- (
replicate, ).
pvalfun <- function() {
g <- update(g0,data=transform(ex,group=sample(group)))
coef(summary(g))["score","Pr(>|z|)"]
}
res <- replicate(1000,pvalfun())
library(plyr)
res <- raply(1000,pvalfun(),.progress="text")
library(glmperm)
ptest2 <- prr.test(group~score,"score",data=ex,family=binomial)
summary(ptest2)