[R-SIG-Finance] Rmetrics TimeSeries Class

Thomas Etheber etheber at gmx.de
Thu Dec 9 10:56:39 CET 2010


Did you already try something like...

DXY.S <- timeSeries(DXY[,-1], DXY[,1])



On 09.12.2010 07:21, JOSH CHIEN wrote:
> Hi All R user,
> I'm being trouble with converting timeSeries Class on Rmetrics lib.
>
> I use "read.cvs" function to import data.
> data is data.frame class. But, I need to convert into timeSeries class.
>
> Below is my example.
>
> # I can't convert into timeSeries class. I don't why ???
> Anyone can handle that ????
>
> class(data) = data.frame
> class(DXY) = data.frame / class(DXY$Date) = Date
>
>> head(data)
>          Date lastPrice Vol10 Vol30 Vol90 Vol60 Vol180 Vol260 Vol360
> 1 2010/01/04    77.525  4.66  9.18  8.21  8.42   9.62  10.78  12.34
> 2   2010/1/5    77.619  4.38  8.80  8.21  8.37   9.51  10.76  12.34
> 3   2010/1/6    77.493  3.90  8.83  8.10  8.37   9.49  10.72  12.33
> 4   2010/1/7    77.913  4.63  8.12  8.12  8.34   9.47  10.73  12.32
> 5   2010/1/8    77.471  5.49  8.20  8.17  8.44   9.49  10.72  12.33
> 6  2010/1/11    77.005  6.28  8.48  8.20  8.54   9.51  10.70  12.34
>>   DXY<- transform(data,Date = as.Date(Date))
>> head(DXY)
>          Date lastPrice Vol10 Vol30 Vol90 Vol60 Vol180 Vol260 Vol360
> 1 2010-01-04    77.525  4.66  9.18  8.21  8.42   9.62  10.78  12.34
> 2 2010-01-05    77.619  4.38  8.80  8.21  8.37   9.51  10.76  12.34
> 3 2010-01-06    77.493  3.90  8.83  8.10  8.37   9.49  10.72  12.33
> 4 2010-01-07    77.913  4.63  8.12  8.12  8.34   9.47  10.73  12.32
> 5 2010-01-08    77.471  5.49  8.20  8.17  8.44   9.49  10.72  12.33
> 6 2010-01-11    77.005  6.28  8.48  8.20  8.54   9.51  10.70  12.34
>> DXY.S<- as.timeSeries(DXY)
>> head(DXY.S)
> GMT
>                      lastPrice Vol10 Vol30 Vol90 Vol60 Vol180 Vol260 Vol360
> 1970-01-01 04:03:33    77.525  4.66  9.18  8.21  8.42   9.62  10.78  12.34
> 1970-01-01 04:03:34    77.619  4.38  8.80  8.21  8.37   9.51  10.76  12.34
> 1970-01-01 04:03:35    77.493  3.90  8.83  8.10  8.37   9.49  10.72  12.33
> 1970-01-01 04:03:36    77.913  4.63  8.12  8.12  8.34   9.47  10.73  12.32
> 1970-01-01 04:03:37    77.471  5.49  8.20  8.17  8.44   9.49  10.72  12.33
> 1970-01-01 04:03:40    77.005  6.28  8.48  8.20  8.54   9.51  10.70  12.34
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>



More information about the R-SIG-Finance mailing list