[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-sig-finance
Subject:    Re: [R-SIG-Finance] expanding xts object - adding a day
From:       "Brian G. Peterson" <brian () braverock ! com>
Date:       2011-10-31 13:10:07
Message-ID: 1320066607.12096.105.camel () brian-rcg
[Download RAW message or body]


On Mon, 2011-10-31 at 13:58 +0100, Martin Bauer wrote:
> Hi Brian,
> 
> yes rbind finally but I thinking of something like this - not sure if that could lead to a solution


<snipped because it doesn't make any sense>

> I'm lost at this point

Clearly.

> getSymbols('SPY')
[1] "SPY"
> tail(SPY)
           SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted
2011-10-21   123.09   124.12  122.72    123.97  278872100       123.97
2011-10-24   124.17   125.80  124.06    125.49  202862400       125.49
2011-10-25   124.89   124.95  122.78    123.05  268433100       123.05
2011-10-26   124.35   124.77  122.21    124.30  288818700       124.30
2011-10-27   127.63   129.42  124.32    128.63  389788900       128.63
2011-10-28   128.00   128.85  127.80    128.60  225638800       128.60

>SPY<-rbind(SPY,xts(matrix(c(126.5,126.6,126.425,126.55,NA,NA),nrow=1),order.by=as.Date(Sys.Date())))

> tail(SPY)
           SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted
2011-10-24   124.17   125.80 124.060    125.49  202862400       125.49
2011-10-25   124.89   124.95 122.780    123.05  268433100       123.05
2011-10-26   124.35   124.77 122.210    124.30  288818700       124.30
2011-10-27   127.63   129.42 124.320    128.63  389788900       128.63
2011-10-28   128.00   128.85 127.800    128.60  225638800       128.60
2011-10-31   126.50   126.60 126.425    126.55         NA           NA

You don't need anything other than rbind and xts.

-- 
Brian

_______________________________________________
R-SIG-Finance@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.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic