Skip to content
Prev 304470 / 398503 Next

Sorting of columns of a matrix

Hi
<snip>
<snip>
I am not sure what do you want to do with it? Remove rows which has 0

X[X==0]<-NA
X[complete.cases(X),]

remove zeroes and sort values independently in each column?

X[X==0]<-NA
apply(X, 2, sort, decreasing=TRUE)

results in list as you have various number of values in columns.

Regards
Petr