[R] Simple if else statement problem
Jim Burke
j.burke at earthlink.net
Fri Nov 13 18:39:09 CET 2009
Anna,
I think the else needs to be on the same line
as the curly bracket like this "} else".
P1 <- 1
P2 <- 2
if( P2 > P1)
{
P<-P2
} else
{
P<-P1
}
Good luck,
Jim
anna_l wrote:
> Hello, I am getting an error with the following code:
> if( P2 > P1)
> + {
> + P<-P2
> + }
>
>> else
>>
> Erro: unexpected 'else' in "else"
>
>> {
>>
> + P<-P1
> + }
>
> I checked the syntax so I don´t understand, I have other if else statements
> with the same syntax working. Thanks in advance
>
More information about the R-help
mailing list