[Rd] function "apply" and 3D arrays (PR#7221)

From: <jaroslaw.w.tuszynski_at_saic.com>
Date: Fri 10 Sep 2004 - 04:01:32 EST


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



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri Sep 10 04:12:49 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:00:15 EST