[R] syntax error in function 'for'

John Fox jfox at mcmaster.ca
Wed May 5 17:53:17 CEST 2004


Dear Ulrich,

I believe that you want ifelse(), not if(), but there are likely some other
problems lurking here: You're removing missing data independently from the
several vectors -- unless the NAs are all in the same places, things will
not work or not work correctly. As well, what do you want to happen if the
condition fails?

John 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Ulrich Leopold
> Sent: Wednesday, May 05, 2004 10:06 AM
> To: R-help
> Subject: [R] syntax error in function 'for'
> 
> 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?
> 
> I am using R 1.8.1 on Linux, Kernel 2.4.21-i686.
> 
> Regards, Ulrich
> 
> --




More information about the R-help mailing list