[R] break function execution

Peter Langfelder peter.langfelder at gmail.com
Tue Sep 28 21:30:09 CEST 2010


On Tue, Sep 28, 2010 at 12:18 PM, Greg Snow <Greg.Snow at imail.org> wrote:
> Ctrl-C works on some platforms, it would help us to help you if we knew which OS you are using, which version of R you are using, and in some cases whether you are using the GUI or Terminal version of R.

>> Hi,
>>
>> I have an R function that executes for a little over a minute. When the
>> function starts running, the R interface freezes and doesnt change
>> until the function exits cleanly. Is there someway I can force the
>> function to exit without messing up the interface?(An equivalent of
>> Ctrl-C)
>>
>> Additionally, can I run the function in background and get a
>> notification when it completes?

On Windows you need to press the Escape (Esc) key. However, some
compiled functions are not programmed to be interruptible and neither
Ctrl-C nor Esc will stop them.

As far as I know, there's no way to run something in the background
from the interactive R prompt (there may be a way to hack it together
using threads, but not on all platforms), but you can always write a
full script and use R CMD BATCH to run it in batch mode, possibly in
the background.

Peter



More information about the R-help mailing list