Forum: help


abstracting symbol xts objects [ Reply ] By: andrew a on 2011-10-14 20:40 | [forum:5051] |
I'd like to reference the xts objects returned by getSymbols() as items in a list or vector of objects so my code would not have to know the names of the symbols: i.e. if I do something like: symbols = c("IBM","GE") for(symbol in symbols){ stock(symbol, currency="USD",multiplier=1) } getSymbols(symbols, src='yahoo', index.class=c("POSIXt","POSIXct"),from=initDate) then I'd like to do something somehow populate a list or vector of securities[] objects such that securities[1] = IBM (the xts object, not the string "IBM) and securities[2] = GE i.e. create securities[] such that head(securities[1]) would print: IBM.Open IBM.High IBM.Low IBM.Close IBM.Volume IBM.Adjusted 2009-01-05 86.42 87.67 86.18 86.82 8315700 82.46 2009-01-06 87.11 90.41 86.37 89.23 9649500 84.75 etc............ securities[] should be dynamically sized according to how many xts instrument objects were created and filled in the getSymbols() method (i.e. could be more than 2) I'd appreciate any suggestions you might have. securities<-as.list( |