-4

I get an error 'argument is of length zero' when I try to use this:

mysize <- nrow(rates)
count <- 0
for(i in 1:mysize - 3) {

thisone <- Int[i+1] - Int[i]
nextone <- Int[i+2] - Int[i]
lastone <- thisone + nextone
if (lastone > 0){
count = count +1}
}
count

Sample of rates:

rates Date Int 1 Jan-1959 5.00 2 Feb-1959 5.00 3 Mar-1959 5.00 4 Apr-1959 5.00 5 May-1959 5.00 6 Jun-1959 5.00 7 Jul-1959 5.00

I can't see how to get email notification of replies here..

Ahh... Thom Quinn.. thankyou. That's the answer.

Sorry for the mess here, the format and operation of the board has me a little confused I think. Job's done. I'll go away.

July 2019.

I'm told I'm in danger of being blocked from asking questions. Because, it says, my earlier questions have been questioned, sort of. I've only ever asked four questions. I think this one with the '-4' rating(?) must be the problem. So I want to fix things.

But they won't let me delete it because others have put work in on it.

So I have to come to grips with it.

One objector says the question has been asked before. I can do nothing about that. I didn't know, don't know and don't know what I can do.

Another objector says there's an answer elsewhere and again I don't know anything about that. I can't see how that question with its answer is anything to do with my question

So I'm stuck. Can't do any more than this, it seems.

Reading through the voluminous 'help' and education screens I don't see any other avenue for me to try to repair this situation.

It's not dire, four questions in as many years its obviously not something I lean on heavily, but it is annoying with its red warning and the implication that I'm some kind of bad boy who won't behave.

In the absence of some clear way for me to fix the situation I feel I'm being unfairly maligned.

I do. :)

user577111
  • 191
  • 1
  • 1
  • 9

1 Answers1

2

When you type 1:mysize - 3, R creates the vector 1:mysize, then subtracts 3 from each element in that vector. What you want is 1:(mysize - 3).

Thom Quinn
  • 308
  • 1
  • 7
  • i think this question of mine must be why I can't post any more questions. But I can't see what to do about it. It won't let me delete it. I've written way back in Dec 2016 - when I actually posted it, it seems - that I've got the answer and said 'sorry' for posting it.. what more can I do? – user577111 Nov 16 '17 at 10:04