Skip to content

expanding xts object - adding a day

2 messages · Martin Bauer, Brian G. Peterson

#
Hi Brian,

yes rbind finally but I thinking of something like this - not sure if that could lead to a solution

library(xts)
library(quantmod)
sym=getSymbols("SPY",from="1900-01-01")
l=list()
L$Open <- xts(222, as.Date("2011-10-30"))
L$High <- xts(224, as.Date("2011-10-30"))
L$Low <- xts(220, as.Date("2011-10-30"))
L$Close <- xts(224, as.Date("2011-10-30"))
L$Volume <- xts(999, as.Date("2011-10-30"))
L$Adjusted <- xts(224, as.Date("2011-10-30"))
do.call("merge", L)
rbind(SPY,L)

but I get this error msg

Error in try.xts(list(Open = 222, High = 224, Low = 220, Close = 224,  : 
  Error in UseMethod("as.xts") :   no applicable method for 'as.xts' applied to an object of class "list"

I try this too
instead l=list()  I replaced it with l=xts()

also 

L<- xts(as.Date("2011-10-30",222,224,220,224,999,224))

ended with this error

Error in strptime(x, format, tz = "GMT") : invalid 'x' argument

I'm lost at this point



-------- Original-Nachricht --------
--
#
On Mon, 2011-10-31 at 13:58 +0100, Martin Bauer wrote:
<snipped because it doesn't make any sense>
Clearly.
[1] "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.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.