Well, you already have base and plyr . Here is the third option in such matters:
require(data.table) DT <- data.table(dogframe) DT[,b:=sample(b),by=a]
This overwrites column b ; if you want it in a separate copy, you would do:
DT2 <- copy(DT)[,b:=sample(b),by=a]
Frank source share