jeudi 21 décembre 2017

randomly swapping the values between two columns but still maintaining row identity

I have a data set with responses for before and after. that looks something like this...

before <- c(2,4,5,4,3) after <- c(4,4,5,4,4) and so on but in a data frame of rows and columns .

I want to do a permutation test where each value will stay in its row but could switch columns randomly. Not every row needs to switch but it will be random every time. I want to do it a lot of times in a for loop I think to asses the mean and how it changes. How can I do this?




Aucun commentaire:

Enregistrer un commentaire