Re: [R] why doesn't ifelse work ?

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Fri, 29 Apr 2011 00:24:01 -0400

On Apr 28, 2011, at 10:28 PM, eric wrote:

> equire(quantmod)
> require(PerformanceAnalytics)
> rm(list=ls())
> getSymbols("^GSPC", src="yahoo", from="1990-01-01", to=Sys.Date())
> GSPC <-na.omit(Ad(GSPC))
> ind <- rollapply(GSPC, 200, mean)
> signal <- ifelse(diff(ind, 5) > 0 , 1 , -1)
> signal[is.na(signal)] <- 0

 > table(coredata(diff(ind,5)) >0)

FALSE TRUE
  1286 3886

>
> --
> View this message in context: http://r.789695.n4.nabble.com/why-doesn-t-ifelse-work-tp3482680p3482737.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 29 Apr 2011 - 04:28:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 29 Apr 2011 - 04:40:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive