Re: [R] apply command

2010-01-19 Thread Dennis Murphy
Hi: Per Baptiste's suggestion (not the iapply one, the plyr one :) > aaply(b, 1, function(x) sort(x, na.last = FALSE)) Var1 1 2 3 4 5 6 1 1 2 4 5 7 9 2 NA 2 3 3 3 5 HTH, Dennis On Tue, Jan 19, 2010 at 2:27 AM, marco salvini wrote: > Can you please help on the issue? > I using the appl

Re: [R] apply command

2010-01-19 Thread Tal Galili
Thank you for the answer Linlin, I am wondering, is there a way to change it so that R will fill matrix's by rows ? Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) |

Re: [R] apply command

2010-01-19 Thread Linlin Yan
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, fu

Re: [R] apply command

2010-01-19 Thread baptiste auguie
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 : > Can you please help on the issue? > I using the apply command on a matrix below the example: > > Create a vector > x =c(5, 3, 2:4, NA, 7,

Re: [R] apply command

2010-01-19 Thread Tal Galili
Hello Marco What I would do, is use "t" to transpose the matrix. Why it is that apply switches the matrix, is beyond my knowledge - and I would love to read more informed replies. Tal Contact Details:--- Contact me: tal.gal...

[R] apply command

2010-01-19 Thread marco salvini
Can you please help on the issue? I using the apply command on a matrix below the example: Create a vector x =c(5, 3, 2:4, NA, 7, 3, 9, 2, 1, 5) create a matrix of 2 rows by 6 columns b=matrix(x, 2,6) print(b) [,1] [,2] [,3] [,4] [,5] [,6] [1,]524791 [2,]33