Currently, when you select multiple expressions and run the selection in the console, the second and subsequent expressions are still run even if the first one fails with an error. Often it doesn't make sense, since the the expressions are sequenced so that the subsequent expressions depend of the prior ones being evaluated successfully. This results in a messy console with multiple errors and makes it difficult to find the original error.
Wrapping the whole selection on-the-fly with curly braces ({}) before pasting it in the console and executing it (to make it a one big ad-hoc temporary expression) will be enough to make R stop and not run all the following sub-expressions if any single one of them results in an error. I suggest to add this option to the plain old "run the selection" (Ctrl + Enter).
Example:
Current behaviour after "run selection":
Assume the source code selection:
a <- stop('a cannot be calculated')
a + b
Result:
> a <- stop('a cannot be calculated')
Error: a cannot be calculated
> a + b
Error: object 'a' not found
Requested behaviour for the new "run selection as expression":
Assume the source code selection (same as before):
a <- stop('a cannot be calculated')
a + b
However, now executed as:
{
a <- stop('a cannot be calculated')
a + b
}
Cleaner result:
> {
+ a <- stop('a cannot be calculated')
+ a + b
+ }
Error: a cannot be calculated