I created a dummy dataset based on your's
data = data.frame(c("ES00","ES00","ES11","ES11","ES12","ES12"),c(2006,2007,2006,2007,2006,2007),c(0,0,12,13,14,15))
names(data) = c("Region","Year","amount")
so this looks like following:
data
Region Year amount
1 ES00 2006 0
2 ES00 2007 0
3 ES11 2006 12
4 ES11 2007 13
5 ES12 2006 14
6 ES12 2007 15
You can use a loop for every year in your data base and do the following:
data$amount[(data$Year==2006) & data$Region=="ES00"] = sum(data$amount[(data$Year==2006)&(data$Region!="ES00")])
If you want to get a little bit more fancy you can use plyr
library
and since your metrics for region ES00 are 0 do the following:
ddply(data,.(Year),summarize, new_amount =sum(amount))
which will look something like this:
Year new_amount
1 2006 26
2 2007 28