Skip to content

apply command

6 messages · marco salvini, Tal Galili, Baptiste Auguie +2 more

#
Hi,

I think you could use iapply (search the archives) or the plyr package
to save you from transposing the result.

HTH,

baptiste

2010/1/19 marco salvini <marco.salvini at gmail.com>:
#
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: