[R] A zoo related question

From: Bogaso Christofer <bogaso.christofer_at_gmail.com>
Date: Thu, 07 Apr 2011 01:27:18 +0530


Dear all, please consider my following workbook:  

library(zoo)

lis1 <- vector('list', length = 2)

lis2 <- vector('list', length = 2)

lis1[[1]] <- zooreg(rnorm(20), start = as.Date("2010-01-01"), frequency = 1)

lis1[[2]] <- zooreg(rnorm(20), start = as.yearmon("2010-01-01"), frequency = 12)  

lis2[[1]] <- matrix(1:40, 20)

lis2[[2]] <- matrix(41:80, 20)  

Now I want to make each element of 'lis2' as zoo object where the corresponding indices will be borrowed from 'lis1'. This means:  

for (i in 1:2) {

                                lis2[[i]] <- zoo(lis2[[i]],
index(lis1[[i]]))
                }

 

However is there any faster way to do that? I found that if the sizes of lis1 & lis2 is quite big then it takes lot of time to complete.  

Any help will be really appreciated.  

Thanks,

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 06 Apr 2011 - 19:39:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 06 Apr 2011 - 20:20:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive