I have the following data read into R as a data frame named "data_old":
   yes year month
1  15 2004     5
2   9 2005     6
3  15 2006     3
4  12 2004     5
5  14 2005     1
6  15 2006     7
.   .  ...     .
.   .  ...     .
I have written a small loop which goes through the data and sums up the yes variable for each month/year combination:
year_f <- c(2004:2006)
month_f <- c(1:12)
for (i in year_f){
    for (j in month_f){
        x <- subset(data_old, month == j & year == i, select="yes")
        if (nrow(x) > 0){
            print(sum(x))
            }
        else{print("Nothing")}
        }
    }
My question is this: I can print the sum for each month/year combination in the terminal, but how do i store it in a vector? (the nested loop is giving me headaches trying to figure this out).
Thomas
 
     
     
     
    