Skip to content
Back to formatted view

Raw Message

Message-ID: <1337803099647-4631128.post@n4.nabble.com>
Date: 2012-05-23T19:58:19Z
From: Hans Thompson
Subject: applying cbind (or any function) across all components in a list

#If I have two lists as follows

a1<-  array(1:6, dim=c(2,3))
a2<-  array(7:12, dim=c(2,3))
l1<-  list(a1,a2)



a3<-  array(1:4, dim=c(2,2))
a4<-  array(5:8, dim=c(2,2))
l2<-  list(a3,a4)


#how can I create a new list with the mean across all arrays within the
list, so all components are included?  As an example for [[1]];

cbind((l1[[1]][,1]+l2[[1]][,1])/2, (l1[[1]][,2]+l2[[1]][,1])/2,
(l1[[1]][,2]+l2[[1]][,2])/2, (l1[[1]][,3]+l2[[1]][,2])/2)



--
View this message in context: http://r.789695.n4.nabble.com/applying-cbind-or-any-function-across-all-components-in-a-list-tp4631128.html
Sent from the R help mailing list archive at Nabble.com.