I need to create several matrices based on two criterion: ideo and time. 
Here is a part of my code which does not work. I see the problem in using list object to store the numbers from new subsets but I don't know the way to list i and j simultaneously in the list. Should I make list(list())? What other ways to code this problem?  
ideo.list<-list(f1,f2,f3,f4,f5,f6,f7,f8,f9)
time.list<-list(t1,t2,t3,t4)
dattime.list<-list()
for (j in 1:length(time.list)){
  for (i in 1:length(ideo.list)){
    dat.sub<-subset(dat,iyear %in% time.list[[j]] & Ideo %in% ideo.list[[i]])
    dattime.list[[i*j]]<-apply(dat.sub[,5:13],2,sum)
}}
nn<-matrix(unlist(dattime.list), byrow=TRUE, ncol=9,nrow=length(dattime.list) )
The head of input data is below:
iyear                                                     Ideo Armed.Assault Assassination
1  1982 Separatist / New Regime Nationalist / Ethnic Nationalist             0             0
2  1994 Separatist / New Regime Nationalist / Ethnic Nationalist             0             0
3  1995                   Left Wing Terrorist Groups (Anarchist)             0             0
4  2010                                  Racist Terrorist Groups             1             0
5  2013                   Left Wing Terrorist Groups (Anarchist)             0             0
6  2014                       Cell Strategy and Terrorist Groups             0             0
  Bombing.Explosion Facility.Infrastructure.Attack Hijacking Hostage.Taking..Barricade.Incident.
1                 1                              0         0                                   0
2                 0                              1         0                                   0
3                 0                              1         0                                   0
4                 0                              0         0                                   0
5                 0                              1         0                                   0
6                 0                              1         0                                   0
  Hostage.Taking..Kidnapping. Unarmed.Assault Unknown
1                           0               0       0
2                           0               0       0
3                           0               0       0
4                           0               0       0
5                           0               0       0
6                           0               0       0
Thank you for help!
