PS> [...] ifelse( x[ x >= 0 & x <= 90 ], 90-x, ifelse( x[ x > 90 & x
PS> <= 180 ], -(x-90), ... ), but that hasn't worked.
Hmmmh, I am not sure what the x[...] does around the conditional. The
basic idea works just fine with me:
> z <- (0:(360*5))/5
> y <- ifelse(z<=90,90-z,ifelse(z<=180,-(z-90),z-270))
> plot(z,y)
Of course,
> x <- abs(z-180)-90
> plot(z,x)
Is perhaps much clearer. And it gives the correct answer too :-)
> max(abs(x-y))
[1] 1.421085e-14
Cheers,
Berwin
=============================== Full address ================================
Berwin A Turlach
Centre for Mathematics and its Applications Tel.: +61 (2) 6249 0706 (Secr.)
Statistical Science Program +61 (2) 6249 0731 (direct)
The Australian National University FAX : +61 (2) 6249 5549
Canberra ACT 0200 e-mail: berwin.turlach@anu.edu.au
Australia http://wwwmaths.anu.edu.au/~berwin
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news