1

I don't know if it has to do with a new version of RStudio or what, but before when I ran a code and an error was encountered R did not stop at the error and it kept running all the selected code or text. However, now whenever an error is encountered R stops. For instance, when I run this code,

Example error
plot(cars)

I only get this result:

> Example sentence
Error: unexpected symbol in "Example sentence"

I'd like R to run all the code, whether there are errors or not, by default. How can I do that?

halfer
  • 19,824
  • 17
  • 99
  • 186
jota_tepe
  • 13
  • 3
  • 2
    your looking for `try()` or `tryCatch()` – D.J Sep 01 '22 at 10:40
  • Read `?try` and `?conditions`. – nicola Sep 01 '22 at 10:40
  • 1
    Thanks for the early replies! I've tried those, but what I actually want is to change to default mode into avoiding to have my code stopped anytime. That is, changing the default options so as to be able to run the code without ever stopping because of an error. Maybe I still don't understand the extent to which the packages can work and I didn't understand correctly your answers. Sorry in advance if this is the case! – jota_tepe Sep 01 '22 at 14:51

1 Answers1

4

You're absolutely correct about this being related to a new version of RStudio; this behavior changed in a recent release (2022.07) because -- most of the time -- if your code encounters an error there's no point in running the remainder of it, plus you want to stop and look at the error.

We're considering making this behavior optional since a lot of people prefer the old behavior. Please comment/upvote this feature request:

https://github.com/rstudio/rstudio/issues/10391

Jonathan
  • 8,497
  • 41
  • 35
  • As an aside, here's a post made by someone asking for exactly the opposite behavior: https://stackoverflow.com/questions/55043745/how-to-make-rstudio-stop-when-meeting-error-or-warning?rq=1 – Jonathan Sep 07 '22 at 20:56
  • I deal with a variety of different datasets and I process them all with the same master template. Some lines are obsolete depending on the task (so errors don't bother me). I understand why some people might like the new behaviour, but it would be good if this was an option, like `option(warn=0)` for instance. Hanging out for you guys making this feature optional. I'll upvote the feature request on git. – chipsin Oct 24 '22 at 11:25