i have a matrix, consisting of monthly values from 2004 to 2018. i would like to split and save these into the individual years with the corresponding months. Like this
...
Sigma.ma2004 <- Sigma.ma[1:12,]
Sigma.ma2005 <- Sigma.ma[13:24,]
Sigma.ma2006 <- Sigma.ma[25:36,]
Sigma.ma2007 <- Sigma.ma[37:48,]
Sigma.ma2008 <- Sigma.ma[49:60,]
Sigma.ma2009 <- Sigma.ma[61:72,]
Sigma.ma2010 <- Sigma.ma[73:84,]
Sigma.ma2011 <- Sigma.ma[85:96,]
Sigma.ma2012 <- Sigma.ma[97:108,]
Sigma.ma2013 <- Sigma.ma[109:120,]
Sigma.ma2014 <- Sigma.ma[121:132,]
Sigma.ma2015 <- Sigma.ma[133:144,]
Sigma.ma2016 <- Sigma.ma[145:156,]
Sigma.ma2017 <- Sigma.ma[157:168,]
Sigma.ma2018 <- Sigma.ma[169:180,]
...
I tried to create a loop for it.
...
start_var <- seq(from = 1 ,to = 169, by = 12)
end_var <- seq(from = 12, to = 180, by = 12)
for (i in 1:length(start_var)){
for(j in 2004:2018){
assign(paste("Sigma.ma",j,sep=""), Sigma.ma[start_var[i]:end_var[i],])
}
}
...
The individual parts are saved, but all with the same strange values.
where is the mistake?