Skip to content
Prev 206791 / 398503 Next

apply command

I guess that the matrix dimension changed because matrix in R are
filled by columns. Since you try:
apply(b, 1, function(y) sort(y, na.last=F))
The second parameter make it scan matrix b row by row but store result
by columns, which make the result be a matrix transposed.
If you try:
apply(b, 2, function(y) sort(y, na.last=F))
The second parameter means scan column by column, and the result
matrix will have the same dimension with origin.
On Tue, Jan 19, 2010 at 6:31 PM, Tal Galili <tal.galili at gmail.com> wrote: