Displaying 1 result from an estimated 1 matches for "tdata2".
Did you mean:
data2
2011 Apr 29
3
why doesn't ifelse work ?
I have the following lines of code:
ind <- rollapply(GSPC, 200, mean)
signal <- ifelse(diff(ind, 5) > 0 , 1 , -1)
signal[is.na(signal)] <- 0
I never get a value of -1 for signal even though I know diff(ind , 5) is
less than zero frequently. It looks like when diff(ind , 5) is less than
zero, signal gets set to 0 instead of - 1. Any ideas why ? Here's some
information on ind and