Dear all, I have some problem with zoo object. So it will really be very
helpful if somebody helps me to fix that. Here I have created a zoo object:

 

library(zoo)

MyData <- zooreg(1:20, start = as.Date("2010-02-03"))

 

This is vector, so I want to convert it a matrix with number of columns as
'1'. But use of as.matrix(MyData) change the 'zoo' class

 

 

> MyData1 <- as.matrix(MyData)

> is.zoo(MyData1)

[1] FALSE

 

So my question is, how I can change from vector to a one-column matrix, but
preserving the zoo attribute?

 

I have another question on that. Let say I have following zoo object:

 

> MyData <- zooreg(matrix(1:20, nc = 1), start = as.Date("2010-02-03"))

> MyData1 <- window(MyData, start = as.Date('2010-02-16'), end =
as.Date('2010-02-20')); MyData1

2010-02-16 2010-02-17 2010-02-18 2010-02-19 2010-02-20 

        14         15         16         17         18 

> Data <- coredata(MyData1)

> is.matrix(Data)

[1] FALSE

 

 

Therefore you see that, as soon as I applied window() function on 'MyData'
resulting object becomes vector. Although the coredata of 'MyData1' was
generated with some 'matrix operation'

How can I make 'Data' as matrix, with some minimal work?

 

Thanks,


	[[alternative HTML version deleted]]

