I have a dataframe (df1) like this.
f1 f2 f3 f4 f5 d1 1 0 1 1 1 d2 1 0 0 1 0 d3 0 0 0 1 1 d4 0
You can also "sample" the same number of items in your data frame with something like this:
nr<-dim(M)[1] random_M = M[sample.int(nr),]