[R-SIG-Finance] merging tseries with a table

Brian G. Peterson brian at braverock.com
Tue Sep 29 16:58:14 CEST 2015


On Tue, 2015-09-29 at 10:39 -0400, aschmid1 wrote:
> I'm trying to merge prices obtained with get.hist.quote():
> > head(mkt_prc)
>             AdjClose
> 2009-01-02 36.21114
> 2009-01-05 36.04547
> 2009-01-06 36.42040
> 2009-01-07 35.34793
> 2009-01-08 35.40897
> 2009-01-09 34.67655
> 
> with data from a csv table:
> > head(gdp_tab)
>         Date Actual
> 1 1/31/2001    1.4
> 2 2/28/2001    1.1
> 3 3/29/2001    1.0
> 4 4/27/2001    2.0
> 5 5/25/2001    1.3
> 6 6/29/2001    1.2
> 
> I use command (as far as my imagination goes):
>   x<-merge(gdp_tab, mkt_prc, by.x="Date", by.y=index(mkt_prc))
> 
> and it gives me an error:
> Error in fix.by(by.y, y) : 'by' must match numbers of columns
> 
> Any suggestions on how to do this?

Yes, use xts, getSymbols rather than get.hist.quote, and rbind.


-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list