Hi, I guess it is because I spread the command in different rows. Thank you very much for your help.
Petr Pikal wrote: > > Hi > > [EMAIL PROTECTED] napsal dne 11.12.2007 13:06:14: > >> >> Hello everyone, >> >> I would like to use the "if" statements and I was thinking sth like >> >> If () {} else{ if() {} else{} } >> >> Is this a possible solution and is there any syntax error? > > Except the first letter, nothing sooms to be wrong. > >> if (1==1) {print("a")} else { if(1==1) {print("b")} else{print("c")} } > [1] "a" >> if (1==2) {print("a")} else { if(1==1) {print("b")} else{print("c")} } > [1] "b" >> if (1==2) {print("a")} else { if(1==2) {print("b")} else{print("c")} } > [1] "c" >> > > I beleive you noticed a difference between if() and ifelse() functions. > And of course if you spread your command in several rows be carefull not > to have valid syntax before you ended a whole command. > e.g. > if (1==2) {print("a")} > else { if(1==2) {print("b")} else{print("c")} } > > Error: unexpected 'else' in "else" > > > Regards > Petr > > >> >> Could anyone give me some advice? Many thanks. >> -- >> View this message in context: http://www.nabble.com/If-Else-Function- >> tp14272459p14272459.html >> Sent from the R help mailing list archive at Nabble.com. >> >> ______________________________________________ >> 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@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. > > -- View this message in context: http://www.nabble.com/If-Else-Function-tp14272459p14277285.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.