Skip to content
Back to formatted view

Raw Message

Message-ID: <3A822319EB35174CA3714066D590DCD504AF75D8@usrymx25.merck.com>
Date: 2004-01-09T13:39:43Z
From: Liaw, Andy
Subject: apply to multiple arrays simultaneously

Off the top of my head, seems like you can abind() the two together and then
run apply.  See the abind package on CRAN.

HTH,
Andy

> From: Carlos Soares
> 
> Dear R users,
>  
> Suppose two arrays which partly have the same dimensions. For 
> instance, 
> a1 and a2 with dim(a1) is c(3,4,5,6) and dim(a2) is 
> c(3,4,7,8). How can 
> I perform an apply on the equivalent part of the dimensions on both 
> arrays simultaneously? Something like:
>  
>   apply(list(a1, a2), c(1,2), function(x,y) {my.function(x,y)})
>  
> A useful bonus would be, assuming that my.function always returns an 
> array withthe same dimensions (e.g., c(2,3,4), that the final result 
> would be an array wit
> h dimensions c(3,4,2,3,4).
>  
> With best regards,
> Carlos


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}