Dear Duncan,
But it is entirely different in my case...! As you
said, the problem may be with my version of RStudio. The main point is that it
doesn't pose any serious problems...
Thanks any way for your reply...
Thanking you,
Yours sincerely,
AKSHAY M KULKARNI
________________________________
From: Duncan Murdoch <[email protected]>
Sent: Wednesday, April 12, 2023 5:46 PM
To: akshay kulkarni <[email protected]>; R help Mailing list
<[email protected]>
Subject: Re: [R] aborting the execution of a script...
This is what I get:
> source("~/temp/test.R", echo = TRUE)
> print(1)
[1] 1
> stop("here")
Error in eval(ei, envir) : here
I get similar output in every variation I tried. It never prints the 2.
On 12/04/2023 8:13 a.m., akshay kulkarni wrote:
> Dear Duncan,
> What if I use source() with echo? I am using
> that in RStudio.
>
> THanking you,
> Yours sincerely
> AKSHAY M KULKARNI
> ------------------------------------------------------------------------
> *From:* Duncan Murdoch <[email protected]>
> *Sent:* Wednesday, April 12, 2023 5:35 PM
> *To:* akshay kulkarni <[email protected]>; R help Mailing list
> <[email protected]>
> *Subject:* Re: [R] aborting the execution of a script...
> On 12/04/2023 7:03 a.m., akshay kulkarni wrote:
>> Dear members,
>> I have a script which I source it
>> interactively. I have the following questions:
>>
>>
>> 1. If there is an error in an expression, an error message is printed,
>> but the execution continues till the end of the script. I am sourcing with
>> echo. Is there any way to abort the execution when the first error occurs?
>> This happens with R CMD BATCH. If there is an error midway, an error
>> message is printed in the output
> file and the execution aborts. Is there a way to mimic this with source()?
>> 2. I am trying to abort the execution with ESC key, but again the same
>> thing happens: it aborts the current expression but continues on. How to
>> abort an R script with source()? I am using RStudio in windows.
>
> I don't see this behaviour. If I put this in a script:
>
> print(1)
> stop("here")
> print(2)
>
> then execution stops at the "stop" line if I use source(), or R CMD
> BATCH <file>, or in RStudio, Run or Source gives the same behaviour. I
> think older versions of RStudio would have run all three lines using
> Run, but all the other methods have stopped at the stop() line.
>
> Duncan Murdoch
>
>
>
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
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.