forked from mozillascience/studyGroup
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
questionFurther information is requestedFurther information is requested
Description
Title
Randomise pairwise elements of a matrix
Issue description
I have a matrix of values which are a table of differences.
I want to compare these obs values to a randomly generated null values.
This tests whether my obs values are significant, rather than occur by chance.
I want to keep the identity of the values...and randomise the pairwise comparisons which produced them.
What I have tried
sample function
but I am worried that this creates a non-sensical set of null values
Reproduce the problem
create matrix which shows pairwise differences, like my obs data matrix
m.obs <- matrix(round(runif(10), digits = 2), ncol=16, nrow=16)
m.obs[lower.tri(m.obs)] <- m.obs[upper.tri(m.obs)]
diag(m.obs) <- NA
this m is the same as
m.obs[upper.tri(m.obs)] <- NA
Desired outcome
x <- 1:16
m.null <- m.obs
x.perm <- sample(x, replace = FALSE)
rownames(m.null) <- x.perm
colnames(m.null) <- x.perm
m.null
I want this but where the values are then sorted by the randomised row and colnames
...and I did not accomplish this by already trying sort and order functions
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested