Re: [R] curious about dimension of 'apply' output when MARGIN=1

2007-01-18 Thread Prof Brian Ripley
On Wed, 17 Jan 2007, Patrick Burns wrote: A logical reason for the phenomenon is that matrices are stored down their columns. For example: matrix(1:15,5) [,1] [,2] [,3] [1,]16 11 [2,]27 12 [3,]38 13 [4,]49 14 [5,]5 10 15 When an

Re: [R] curious about dimension of 'apply' output when MARGIN=1

2007-01-18 Thread Robin Hankin
On 18 Jan 2007, at 08:42, Prof Brian Ripley wrote: On Wed, 17 Jan 2007, Patrick Burns wrote: A logical reason for the phenomenon is that matrices are stored down their columns. For example: [snip] Or that the vision of the original designer was not limited to matrices. It just so

Re: [R] curious about dimension of 'apply' output when MARGIN=1

2007-01-18 Thread Benjamin Tyner
Thanks to all for your insightful comments. I must admit I was unaware of the application to arrays. Ben Prof Brian Ripley wrote: Or that the vision of the original designer was not limited to matrices. It just so happens that in this example the replacement is a single dimension the same

Re: [R] curious about dimension of 'apply' output when MARGIN=1

2007-01-17 Thread Patrick Burns
A logical reason for the phenomenon is that matrices are stored down their columns. For example: matrix(1:15,5) [,1] [,2] [,3] [1,]16 11 [2,]27 12 [3,]38 13 [4,]49 14 [5,]5 10 15 When an 'apply' across rows is done, it will be the values

Re: [R] curious about dimension of 'apply' output when MARGIN=1

2007-01-17 Thread Antonio, Fabio Di Narzo
2007/1/17, Patrick Burns [EMAIL PROTECTED]: A logical reason for the phenomenon is that matrices are stored down their columns. For example: matrix(1:15,5) [,1] [,2] [,3] [1,]16 11 [2,]27 12 [3,]38 13 [4,]49 14 [5,]5 10 15 When an

[R] curious about dimension of 'apply' output when MARGIN=1

2007-01-16 Thread Benjamin Tyner
Reading the documentation for 'apply', I understand the following is working exactly as documented: M-matrix(1:6,ncol=2) M [,1] [,2] [1,]14 [2,]25 [3,]36 apply(M,2,function(column) column+c(1,2,3)) [,1] [,2] [1,]25 [2,]47 [3,]69

Re: [R] curious about dimension of 'apply' output when MARGIN=1

2007-01-16 Thread Gabor Grothendieck
The reshape package has an idempotent apply, iapply: library(reshape) iapply(M,1,function(row) row+c(1,2)) [,1] [,2] [1,]26 [2,]37 [3,]48 On 1/16/07, Benjamin Tyner [EMAIL PROTECTED] wrote: Reading the documentation for 'apply', I understand the following is