Re: [R] Simple if else statement problem

2009-11-16 Thread anna_l
thanks petr, this is actually shorter ;) Petr Pikal wrote: > > Hi > > r-help-boun...@r-project.org napsal dne 13.11.2009 18:54:05: > >> >> Ok Jim it worked, thank you! it´s funny because it worked with the first >> syntax in some cases... > > you can use another approach in this case > > P<

Re: [R] Simple if else statement problem

2009-11-15 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 13.11.2009 18:54:05: > > Ok Jim it worked, thank you! it´s funny because it worked with the first > syntax in some cases... you can use another approach in this case P<-max(c(P1,P2)) Regards Petr > > > anna_l wrote: > > > > Hello, I am getting a

Re: [R] Simple if else statement problem

2009-11-13 Thread anna_l
ok thanks guys for the help, indeed I assumed there was an explanation thank you duncan for giving it! -- View this message in context: http://old.nabble.com/Simple-if-else-statement-problem-tp26340336p26343665.html Sent from the R help mailing list archive at Nabble.com. _

Re: [R] Simple if else statement problem

2009-11-13 Thread Peter Ehlers
anna_l wrote: Ok Jim it worked, thank you! it´s funny because it worked with the first syntax in some cases... No, it did not. R doesn't randomly work in different ways on different days. -Peter Ehlers anna_l wrote: Hello, I am getting an error with the following code: if( P2 > P1) + {

Re: [R] Simple if else statement problem

2009-11-13 Thread Duncan Murdoch
On 11/13/2009 12:54 PM, anna_l wrote: Ok Jim it worked, thank you! it´s funny because it worked with the first syntax in some cases... If R knows the whole thing is incomplete, it will accept an else on its own line. If the first 4 lines make a complete statement, R will evaluate it, and not

Re: [R] Simple if else statement problem

2009-11-13 Thread anna_l
Ok Jim it worked, thank you! it´s funny because it worked with the first syntax in some cases... 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 synta

Re: [R] Simple if else statement problem

2009-11-13 Thread Jim Burke
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: unexpe

Re: [R] Simple if else statement problem

2009-11-13 Thread Benilton Carvalho
align the else with the curly brackets if (yes){ be happy }else{ complain } b On Nov 13, 2009, at 3:33 PM, 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´

[R] Simple if else statement problem

2009-11-13 Thread anna_l
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 -- View this message in context: