[R-SIG-Finance] problem subsetting xts object with yearmon time index
Daniel Cegiełka
daniel.cegielka at gmail.com
Fri Mar 20 18:30:00 CET 2015
2015-03-20 18:18 GMT+01:00 Joshua Ulrich <josh.m.ulrich at gmail.com>:
> I can confirm this behavior with a simplified example using zoo 1.7-12
> and the latest development xts.
>
>> data(sample_matrix)
>> x <- as.xts(sample_matrix)
>> y <- to.monthly(x)
>> y['2007']
> x.Open x.High x.Low x.Close
> Feb 2007 50.22448 51.32342 50.19101 50.77091
> Mar 2007 50.81620 50.81620 48.23648 48.97490
> Apr 2007 48.94407 50.33781 48.80962 49.33974
> May 2007 49.34572 49.69097 47.51796 47.73780
> Jun 2007 47.74432 47.94127 47.09144 47.76719
>
>
> Thanks for the report. I'll investigate.
>
> Best,
> Josh
hi,
I can not reproduce this error with zoo-1.7-12 and xts-0.8-0.
> getSymbols('MSFT')
[1] "MSFT"
> x <- xts::to.monthly(MSFT)
> x['2015']
MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
Jan 2015 46.66 47.91 40.35 40.40 918956900 40.11
Feb 2015 40.59 44.30 40.23 43.85 656204800 43.85
Mar 2015 43.67 44.19 40.61 42.29 512133400 42.29
> x['2014']
MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
Jan 2014 37.35 37.89 34.63 37.84 930226200 36.57
Feb 2014 37.74 38.46 35.69 38.31 705304500 37.30
Mar 2014 37.92 41.50 37.49 40.99 778425700 39.91
Apr 2014 41.15 41.66 38.90 40.40 746113500 39.34
May 2014 40.24 40.97 38.51 40.94 574362900 40.15
Jun 2014 40.95 42.29 39.86 41.70 555779700 40.89
Jul 2014 41.86 45.71 41.05 43.16 731616500 42.32
Aug 2014 43.21 45.47 42.21 45.43 513919700 44.83
Sep 2014 45.43 47.57 44.53 46.36 860827300 45.74
Oct 2014 46.27 46.97 42.10 46.95 853235700 46.33
Nov 2014 46.89 50.05 46.73 47.81 522988700 47.47
Dec 2014 47.88 49.06 44.90 46.45 626740700 46.12
Daniel
More information about the R-SIG-Finance
mailing list