Hi I'm using R quantmod library and I would like to find and return the maximum of two values (volume today, vs volume yesterday).
require(quantmod)
getSymbols("HELE")
# Ok now when I do this it does not return a single column with the highest
# volume
head( merge( HELE, max (HELE$HELE.Volume,lag(HELE$HELE.Volume, k=1 ) ) ) )
this generally works because for example say I want to subtract today's high from yesterday close I can do this.
head( merge(HELE, abs(HELE$HELE.High - lag(HELE$HELE.Close, k=1) ) ) )
I also tried apply function but did not work as well,
head( merge(HELE, as.xts(apply( c(lag(HELE$HELE.Volume, k=1 ), HELE$HELE.Volume ), 1, max) ) ) )
Thanks in advance. Ahdee