Skip to content
Prev 318427 / 398502 Next

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

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