[R-SIG-Finance] quantmod: get date column

Guillaume Yziquel guillaume.yziquel at citycable.ch
Fri Dec 11 05:19:23 CET 2009


km a écrit :
> Hi All:
> 
> Is it possible to extract the date column from an xts object? For example:
> 
> library(quantmod)
> getSymbols("F")
> 
>  a <- head(F)
> 
> a
> 
>            F.Open F.High F.Low F.Close F.Volume F.Adjusted
> 2007-01-03   7.56   7.67  7.44    7.51 78652200       7.51
> 2007-01-04   7.56   7.72  7.43    7.70 63454900       7.70
> 2007-01-05   7.72   7.75  7.57    7.62 40562100       7.62
> 2007-01-08   7.63   7.75  7.62    7.73 48938500       7.73
> 2007-01-09   7.75   7.86  7.73    7.79 56732200       7.79
> 2007-01-10   7.79   7.79  7.67    7.73 42397100       7.73
> 
> I want to extract the date column only and assign it to a new variable.
> 
> 
> Thanks in advance,
> Krish

Here you go:

>> getSymbols("F")
> [1] "F"
>> a <- head(F)
>> a
>            F.Open F.High F.Low F.Close F.Volume F.Adjusted
> 2007-01-03   7.56   7.67  7.44    7.51 78652200       7.51
> 2007-01-04   7.56   7.72  7.43    7.70 63454900       7.70
> 2007-01-05   7.72   7.75  7.57    7.62 40562100       7.62
> 2007-01-08   7.63   7.75  7.62    7.73 48938500       7.73
> 2007-01-09   7.75   7.86  7.73    7.79 56732200       7.79
> 2007-01-10   7.79   7.79  7.67    7.73 42397100       7.73
>> index(a)
> [1] "2007-01-03" "2007-01-04" "2007-01-05" "2007-01-08" "2007-01-09"
> [6] "2007-01-10"
>> 

All the best,

-- 
      Guillaume Yziquel
http://yziquel.homelinux.org/



More information about the R-SIG-Finance mailing list