[R] element wise opertation between a vector and a list

Yongwan Chun ywchun at gmail.com
Mon Sep 3 08:36:10 CEST 2007


I want to try to get a result of element wise addition between a
vector and a list. It can be done with "for statement." In order to
reducing computing time, I have tried to avoid "for state." If anybody
give me an idea, I would apprecite it much.

for example, with a & b as below lines,

a<- list(c(1,3),c(1,2),c(2,3))
b<-c(10,20,30)

I would like to have a list (like "d") or a vector (like "e") as below.

d<-list(c((1+10),(3+10)),c((1+20),(2+20)),c((2+30),(3+30)))
e<- c((1+10)+(3+10),(1+20)+(2+20),(2+30)+(3+30))

Thanks,


Yongwan Chun



More information about the R-help mailing list