Re: [R] help on error message!!!

2007-11-04 Thread Bernardo Rangel Tura

On Sun, 2007-11-04 at 15:06 +0100, david csongor wrote:
> Could anyone please  help me with this one!!!
> I am looping some simple stuff but when I enter an if - function I get this
> error message:
> 
> 
> Error in if (y < (2/(1 * pi) * sqrt(1 - ((x - 2)/1)^2))) c[i] = x else c[i]
> = 0 :
> missing value where TRUE/FALSE needed
> 
> 
> WHAT does it mean, what should I do

Try ifelse:

c<-ifelse(y < (2/(1 * pi)*sqrt(1 -(x - 2)^2)),x,c[i])
-- 
Bernardo Rangel Tura, M.D,Ph.D
National Institute of Cardiology
Brazil

__
R-help@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.


Re: [R] help on error message!!!

2007-11-04 Thread Duncan Murdoch
On 04/11/2007 9:06 AM, david csongor wrote:
> Could anyone please  help me with this one!!!
> I am looping some simple stuff but when I enter an if - function I get this
> error message:
> 
> Error in if (y < (2/(1 * pi) * sqrt(1 - ((x - 2)/1)^2))) c[i] = x else c[i]
> = 0 :
> missing value where TRUE/FALSE needed
> 
> WHAT does it mean, what should I do

if ( condition ) requires that the condition evaluate to something that 
it can interpret as TRUE or FALSE.  Your condition was

y < (2/(1 * pi) * sqrt(1 - ((x - 2)/1)^2))

and it evaluated to a missing value.  Several reasons this could happen: 
  y was missing, x was missing, you tried to take a square root of a 
negative number, etc.

Duncan Murdoch

__
R-help@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.


[R] help on error message!!!

2007-11-04 Thread david csongor
Could anyone please  help me with this one!!!
I am looping some simple stuff but when I enter an if - function I get this
error message:


Error in if (y < (2/(1 * pi) * sqrt(1 - ((x - 2)/1)^2))) c[i] = x else c[i]
= 0 :
missing value where TRUE/FALSE needed


WHAT does it mean, what should I do

[[alternative HTML version deleted]]

__
R-help@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.