I have a Time Series data in the form of a list, which has been defined as below
[[1]][[1]] [1] "Product Name"
[[1]][[2]] [1] 20031031 "Starting duration"
[[1]][[3]] [1] 20160831 "Ending Duration"
[[1]][[4]] [1] 0.040816323 0.010141988 0.050318689 0.012804102 0.011378003 "Series of observations"
I for instance try to merge two series using: merge(as.zoo(TS1), as.zoo(TS2))
The functionality works fine when its not inside a loop, and is distorted while being used inside a for loop
startYear = as.numeric(substr(unlist(TimeSeries[[1]][2]),1,4))
startMonth = as.numeric(substr(unlist(TimeSeries[[1]][2]),5,6))
TS1 = ts(unlist(TimeSeries[[1]][4]), start = c(startYear,startMonth),
frequency = 12)
TS2 = ts(unlist(TimeSeries[[2]][4]), start = c(startYear,startMonth),
frequency = 12)
M <- merge(as.zoo(TS1), as.zoo(TS2))
No issues seen here in the above merge
issues seen when same code is used inside a For loop,
for(I in 1:1)
{
M <- merge(as.zoo(TS1), as.zoo(TS2))
}
Why is this happening, and what could possibly be a fix for same