Skip to content

Error in J[time] : invalid subscript type 'closure'

3 messages · Jannetta Steyn, Berend Hasselman, MacQueen, Don

#
On 24-02-2013, at 10:59, Jannetta Steyn <jannetta at henning.org> wrote:

            
Look at your code carefully. The error is staring you in the face.
The second argument in the call of s_fun is "time" which is nit evaluated immediately.
You probably meant "times".

Berend
3 days later
#
In my experience, error messages that include the word "closure" almost
always mean that I have tried to do something with a function that isn't
supposed to be done with a function (undoubtedly not a technically correct
statement, but it works for me).

I think that applies here, since time is a function in the R stats package:
  > find('time')
  [1] "package:stats"

So, consistent with Berend's suggestion, the expression
   s_fun(parms, time)
is passing the time() function to the expression
   J[time]
and it makes no sense to use a function as an index to a numeric vector. I
also believe that is why the error message said, "invalid subscript type".
  

-Don