Displaying 1 result from an estimated 1 matches for "tradedrate".
Did you mean:
tradedate
2009 Oct 12
1
Using diff, ifelse on zoo object
...02-03 -1.3188533 0
2003-02-07 0.2709794 0
2003-02-09 -1.4915262 1
2003-02-14 0.5014170 1
When I create this new zoo object using the previous one (x) I don't get
exactly what I need......the traded rate is based on the lagged values,
rather than the present ones...
TradedRate <- ifelse(abs(diff(x[,"x.POS"],lag= 1))>0,ifelse(x[,"x.POS"]
!=1,-x[,"x"],x[,"x"]),NA)
x <- merge(x, TradedRate, all=TRUE)
x
x x.POS TradedRate
2003-02-01 -0.1858136 0 NA
2003-02-03 -1.3188533 0 NA
2003-02...