s-news
[Top] [All Lists]

Re: [S] Transforming continuous variables

To: Paul.Schwarz@cornell.edu
Subject: Re: [S] Transforming continuous variables
From: Berwin Turlach <berwin.turlach@anu.edu.au>
Date: Mon, 27 Apr 1998 18:02:26 +1000
Cc: s-news@wubios.wustl.edu
In-reply-to: <3.0.2.32.19980426235722.006a21f0@postoffice.mail.cornell.edu> (message from Paul Schwarz on Sun, 26 Apr 1998 23:57:22 -0400)
Sender: owner-s-news@wubios.wustl.edu
>>>>> "PS" == Paul Schwarz <Paul.Schwarz@cornell.edu> writes:

  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

<Prev in Thread] Current Thread [Next in Thread>