Forum: help


RE: xts - add a date [ Reply ] By: Sonja Maz on 2017-02-13 16:33 | [forum:43863] |
thanks a lot Joshua!!!! |
RE: xts - add a date [ Reply ] By: Joshua Ulrich on 2017-02-13 14:55 | [forum:43861] |
Just create an xts object that only contains one row of observations with an index value prior to the start of ALL.ret_2017, and rbind() it with ALL.ret_2017. rbind(ALL.ret_2017, xts(matrix(0,ncol=ncol(ALL.ret_2017)), start(ALL.ret_2017)-1)) Also note that this forum is not active. It would be better to post on R-SIG-Finance. |
xts - add a date [ Reply ] By: Sonja Maz on 2017-02-13 14:38 | [forum:43860] |
Hi @all I use XTS and merge timeseries I downloaded from Bloomberg with RBBG... everything worked fine merging the data in one table called ALL.ret. then I extract data to plot it: ALL.ret_2017 <- ALL.ret['2016-12-31::2017-12-31'] TS1* 2017-01-02 0.041267266 2017-01-03 0.290042066 2017-01-04 0.101768969 2017-01-05 -0.088624073 2017-01-06 -0.095562191 2017-01-09 0.077262767 2017-01-10 -0.053372936 2017-01-11 0.189633493 2017-01-12 -0.303242642 *just copied the first column, actually it has 20 columns My question: How can I add 2017-01-01 with a value of 0 in each column so that it will start at Zero on 2017-01-01 when I plot it? THANKS A LOT!!! Very happy if you could help |