Dear Users,

I am not sure if this is possible.  I would like a command that is capable
of running another command that is within it but stops running if the
command within it is taking too long.

For example it might work like this:

slow.function <- function() {
  a <<- 0
  for (i in 1:10^9) {
   a <<- a+i
  }
}

# Calling it might result in the following:
> flow.control(eval="slow.function", sec.max = 5)
Warning: function slow.function stopped after 5 seconds.
$ seconds = 5
$ break = T

> a
345113

fast.function <- function() {
  a <<- 0
  for (i in 1:10) {
   a <<- a+i
  }
}

> flow.control(eval="fast.function", sec.max = 5)
$ seconds = .000001
$ break = F

> a
55

I know I can design a stopping command to kill an individual loop after a
certain amount of time.  However, I want a catch all function that I can
plug any function into.

Thank you very much for your consideration,
Francis

-- 
Francis Smart
--------------------
PhD Student - Michigan State University
Measurement and Quantitative Methods (MQM)

Blog: www.EconometricsBySimulation.com

Cell: (563) 223-8108

	[[alternative HTML version deleted]]

