From jaroslaw.w.tuszynski at saic.com  Thu Sep  9 20:01:32 2004
From: jaroslaw.w.tuszynski at saic.com (jaroslaw.w.tuszynski@saic.com)
Date: Thu Sep  9 20:01:39 2004
Subject: [Rd] function "apply" and 3D arrays (PR#7221)
Message-ID: <20040909180132.7977A10460@slim.kubism.ku.dk>

Full_Name: jarek tuszynski
Version: 1.8.1
OS: windows 2000
Submission from: (NULL) (198.151.13.10)


Example code:
> a=array(1:27, c(3,3,3))
> apply(a,2, var)
      [,1] [,2] [,3]
 [1,]    1    1    1
 [2,]    1    1    1
 [3,]    1    1    1
 [4,]    1    1    1
 [5,]    1    1    1
 [6,]    1    1    1
 [7,]    1    1    1
 [8,]    1    1    1
 [9,]    1    1    1
> apply(a,2, mean)
[1] 11 14 17
> apply(a,2, sd)
     [,1] [,2] [,3]
[1,]    1    1    1
[2,]    1    1    1
[3,]    1    1    1

I could not figure out from the documentation how MARGIN argument of function
"apply" works in case of arrays with dimentions larger than 2, so I created the
above test code. I still do not know how it suppose to work but I should not get
the results with different dimentions, while calculating var and sd.

Hope this helps,

Jarek


[Rd] function "apply" and 3D arrays (PR#7221)
jaroslaw.w.tuszynski@saic.com