Re: [R] Find the sign

2011-01-24 Thread Francesco Petrogalli
if (x*y>0) {...} On Mon, Jan 24, 2011 at 1:27 PM, Rainer Schuermann wrote: > On Monday, January 24, 2011 07:18:03 pm Alaios wrote: >> Hello :) >> I wanted to right an expression to check when x and y have the same sign >> and I wrote the following: >> >>  if ((x<0 && y<0) || (x>0 && y>0)) >> >> w

Re: [R] Find the sign

2011-01-24 Thread Rainer Schuermann
On Monday, January 24, 2011 07:18:03 pm Alaios wrote: > Hello :) > I wanted to right an expression to check when x and y have the same sign > and I wrote the following: > > if ((x<0 && y<0) || (x>0 && y>0)) > > which looks pretty ugly to me. > > Can you please suggest me a better way for that?

Re: [R] Find the sign

2011-01-24 Thread Henrique Dallazuanna
Try this: !diff(sign(c(x, y))) On Mon, Jan 24, 2011 at 4:18 PM, Alaios wrote: > Hello :) > I wanted to right an expression to check when x and y have the same sign > and I wrote the following: > > if ((x<0 && y<0) || (x>0 && y>0)) > > which looks pretty ugly to me. > > Can you please suggest

[R] Find the sign

2011-01-24 Thread Alaios
Hello :) I wanted to right an expression to check when x and y have the same sign and I wrote the following: if ((x<0 && y<0) || (x>0 && y>0)) which looks pretty ugly to me. Can you please suggest me a better way for that? Regards Alex __ R-help@r-