Re: [R] syntax error in function 'for'

About this list Date view Thread view Subject view Author view Attachment view

From: Peter Wolf (s-plus@wiwi.uni-bielefeld.de)
Date: Thu 06 May 2004 - 01:46:28 EST


Message-id: <40990C54.5000800@wiwi.uni-bielefeld.de>

Ulrich Leopold wrote:

>On Wed, 2004-05-05 at 17:11, Peter Dalgaard wrote:
>
>
>>Ulrich Leopold <uleopold@science.uva.nl> writes:
>>
>>
>>
>>>Dear list,
>>>
>>>I get a syntax error for the following function:
>>>
>>>for(na.omit(sqrt(D))>2) {na.omit(A)-(na.omit(B)+(na.omit(sqrt(C))))}
>>>
>>>Any idea what is wrong?
>>>
>>>
>>Yes, that's not the syntax for a for loop. I have no idea what your
>>intention might have been, though.
>>
>>
>
>Ok thanks. I think I misunderstood the example in the help. I think, I
>rather need an if function.
>
>I would like to calculate the right hand side if the condition on the
>left hand side is met. I am afraid I do not quite understand the syntax.
>
>if(na.omit(sqrt(D))>2) {na.omit(A)-(na.omit(B)+(na.omit(sqrt(C))))}
>
>Now I get the following warning:
>the condition has length > 1 and only the first element will be used in:
>if(na.omit(sqrt(D))>2) {
>
What is the result of the "condition" (1:10) >2 ? What should be done?
Read the text of the warning again.

Peter Wolf

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:07 EST