Skip to content

Trouble sorting the matrix

1 message · Rui Barradas

#
Hello,

Yes, you can do it like you say. Or you can unsort first and multiply later.

mat5.1 <- sapply(seq_len(ncol(ord)), function(i) mat4[order(ord[,i]), i])

multip<-mat4*2
mat5.2 <- sapply(seq_len(ncol(ord)), function(i) multip[order(ord[,i]), i])

identical(mat5.1*2, mat5.2)  #TRUE


Also, it's better if you Cc the list, for others to read and eventually 
find it of some use.

Rui Barradas

Em 15-06-2013 12:48, Ola Cabaj escreveu: