[R] R bug? (if-else problem in main program)
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Wed Nov 6 10:17:27 CET 2002
This is documented in many places. See the help page for `if', or in
fuller detail, section 3.2 of the Language Manual.
The solution is to use braces
if(a == 1) {
print("yes")
} else {
print("no")
}
as described in ?"if".
On Tue, 5 Nov 2002, Anita Gulyasne Goldpergel wrote:
> I've found a very interesting problem in R: the if-else statement doesn't
> work in a main program. Sounds crazy, but true.
This is not `a main program' but using R interactively at the top (prompt)
level. It will work in a function, the only sort of `programs' that exist
in R.
The help and manuals are your friends!
[...]
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list