RStudio feature request: run the selection as expression i.e. inside the curly braces {...}

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

The official forum for bug reports and feature requests is at : Issues · rstudio/rstudio (github.com)

Thank you. Re-posted: RStudio feature request: run the selection as one expression i.e. inside the curly braces {...} · Issue #13848 · rstudio/rstudio · GitHub

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.