samedi 6 juillet 2019

Deeply shuffling a dataframe in R

Im looking for a function or an algorithm to shuffle a dataframe/matrix of floats in R, not by rows or columns only but rather a complete deep randomization of the values.

I tried the function sample() to shuffle the rows first and then the columns but the elements of the same row will end up in the same row just in a different order, im looking more for a complete shuffling.

df =  t1 t2 t3 t3
  g1 1 4 7 0
&nbsp ; g2 8 7 2 9
&nbsp ; g3 4 6 8 1

should result in

df =   t1 t2 t3 t3
  g1 8 2 4 1
  g2 2 1 8 6
  g3 7 9 7 0




Aucun commentaire:

Enregistrer un commentaire