On Sun, Nov 21, 2010 at 10:56:14AM -0500, David Winsemius wrote: > On Nov 21, 2010, at 10:43 AM, madr wrote: > >Is there any way of suppressing that error, like in other programming > >languages you can specifically invoke an error or simply exit, > > If you are in a function, then return() > > >like after > >user input, exiting then is not always identical with error , there > >are > >cases when it is intended behavior. I thought R makes that > >distinction. > > Provide some code. (You did say you had a script.) The answer > probably depends on context and you are not providing any.
A script may reach a condition, when it should stop in different situations. It need not be called using source(). It may be a function called from an extension package. If there is a sequence of several embedded calls than return() cannot be used. For scripts, which i use myself, i use stop() with a parameter, which is a character string explaining the stopping condition. This string is then a part of the generated error message. For scripts, which are used also by other people, i try to avoid this and make sure that after reaching a stopping condition, all cycles and function calls are finished. PS. ______________________________________________ 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.