[R] Maybe not a stable if statement
Leeds, Mark (IED)
Mark.Leeds at morganstanley.com
Tue Nov 21 19:01:44 CET 2006
I have the structure, fxdata, below and I want to only keep data points
of it in which the "bid" and the "ask" column names are both
greater than zero. It's very hard to reproduce my problem because it
seems like the behavior ( whether it gets rid of all the the zeros or
not ) depends on the size of fxdata ?
I had the following line for doing the above :
fxdata<-fxdata[( fxdata[,"bid"] > 0.0 ) & ( fxdata[,"ask"] > 0.0 ),]
But I am thinking that there maybe there is a problem with this
type of approach because of roundoff error ? Does someone know of a more
stable way
of checking this condition ?
There is no need to cut and paste the code above or below because the
above
line above, for certain sizes of temp, does seem to work. But,
then when temp gets too large, it seems to only get some of the zeros ?
I realize this seems strange but I
honestly seemed to have found this, unless I am making a mistake and not
realizing it ? Hs anyone ever had a case where the behavior of an if
statement depended on the size of the object it was working on ? Thanks
a lot.
# fxdata OBJECT
fxdata<-structure(c(109.79, 109.79, 109.79, 109.79, 109.79, 109.79,
109.78,
109.78, 109.78, 109.78, 109.76, 109.76, 109.77, 109.77, 109.77,
109.77, 109.77, 109.77, 109.77, 109.77, 109.77, 109.81, 109.8,
109.81, 109.8, 109.81, 109.8, 0.0, 0.0, 109.8, 109.79, 109.79,
109.78, 0.0, 109.79, 109.8, 109.78, 109.79, 109.8, 109.78,
109.8, 109.78), .Dim = c(21, 2), .Dimnames = list(c("6300", "6301",
"6302", "6303", "6304", "6305", "6306", "6307", "6308", "6309",
"6310", "6311", "6312", "6313", "6314", "6315", "6316", "6317",
"6318", "6319", "6320"), c("bid", "ask")), index =
structure(c(1097576426,
1097576429, 1097576442, 1097576443, 1097576451, 1097576459, 1097576465,
1097576469, 1097576471, 1097576478, 1097576494, 1097576495, 1097576496,
1097576498, 1097576510, 1097576511, 1097576513, 1097576519, 1097576521,
1097576523, 1097576526), class = c("POSIXt", "POSIXct"), tzone = ""),
class = "zoo")
--------------------------------------------------------
This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}
More information about the R-help
mailing list