[R-SIG-Finance] Iterating through subset of XTS object

Noah Silverman noahsilverman at ucla.edu
Tue Jul 5 07:53:50 CEST 2011


Hi,

I have an xts object with 1 minute bars of trading data.

I want to select a subset, then iterate through each bar.  The "obvious" solution doesn't work:

For each bar in the loop, I want to access all the fields (open, close, volume, etc.)


I tried the following, but it doesn't work:

----------------------------------------------
for( one in bars['T10:00/T10"30', ]){
	print(one$open)
	print(one$close)
}
---------------------------------------------

Note: I DO need the loop for the code I'm writing.  

Can someone suggest the proper way to do this?

Thanks!

--
Noah Silverman
UCLA Department of Statistics
8117 Math Sciences Building
Los Angeles, CA 90095



More information about the R-SIG-Finance mailing list