[R] simplify if statement in R ?
Jim Maas
jimmaasuk at gmail.com
Tue Jul 20 20:11:06 CEST 2010
I found a form of the if statement that works but it is very long. I'm
attempting to check the value of of two different variables to see if
they evaluate to either of two different values, which will result in a
division by 0 in the final equation. This first if statement works for me
_______
if ((x0.trial01 == 0.0)||(x0.trial01 == npt01)||(x1.trial01 ==
0.0)||(x1.trial01 == npt01))
{
x0.trial01.in <- x0.trial01 + 0.5
x1.trial01.in <- x1.trial01 + 0.5
npt01.in <- npt01 + 1.0
}
else
{
x0.trial01.in <- x0.trial01
x1.trial01.in <- x1.trial01
npt01.in <- npt01
}
__________
I've tried
if ( ( x0.trial01 || x1.trial01) == ( 0.0 || npt01) )
......
but it doesn't seem to work correctly. Is there a simpler way to check
two variables for two different valuables?
Thanks
J
----
Jim Maas
More information about the R-help
mailing list