Skip to content
Prev 43657 / 398513 Next

Error in f(x, ...) : subscript out of bounds

Jason.L.Higbee at stls.frb.org wrote:

            
Obviously, this is not the original code you have got a problem with, 
since a delimeter is missing the line above. Please don't send code you 
have not tested yourself ....
I'm pretty sure it's a big in your code.

I haven't checked the rest of your code, since it doesn't seem to make 
sense to look into code that is buggy by copy&paste or whatever (see above).

There are *many* lines where your code might result in invalid 
subscripts, depending on the data.

Say length(gsvR$ret) == 1, then:

  lenR <- length(gsvR$ret) # lenR == 1
  for (i in 1:(lenR-1)) {  # 1:(lenR-1) == 1:0 !!!!!
   x[i+1] <- sum(gsvR$rw[1:i]) + 1 # 1:i == 1:0 !!!!!

in for() you might want to use seq(along = gsvR$ret)


Uwe Ligges