I have 3 different daily time-series. Using union() in the "its"
package, I can make a long matrix, where rows are created when even
one of the three time-series is observed:
massive <- union(nifty.its, union(inrusd.its, infosys.its))
Now in this, I want to replace NA values for prices by the
most-recently observed price. I can do this painfully --
for (i in 2:nrow(massive)) {
for (j in 1:3) {
if (is.na(massive[i,j])) {
massive[i,j] = massive[i-1,j]
}
}
}
But this is horribly slow. Is there a more clever way?