0

I have the following solution, which works, but creates an error message.

      day.number.year <- (1:33810)*NA
      day.number.year[] <- rep(seq(1,360, by = 1), times = 94)

Warning message:
In day.number.year[] <- rep(seq(1, 360, by = 1), times = 94) :
  number of items to replace is not a multiple of replacement length

Is there a more elegant option? Basically, the whole NA-Vector should get filled and everything, which extents the vector, should get cut off.

I have to create a vector with the day number of the year for a timespan (2005-2099), but for one year, there is no data for December (2099). Thats why one year has only 330 days. My data is based on a 360 day calendar.

Nucore
  • 107
  • 1
  • 13
  • A warning message is not an error message. The first line should probably be `day.number.year <- rep(NA, 33810)` and the second line does not seem necessary. I think you can do this in a single line with the `length.out` argument: `day.number.year <- rep(1:360, length.out=33810)`. – lmo Jun 20 '17 at 16:09
  • Thank you, that works. Originally, I used length.out, but I must have made a mistake in the end, because it didn't work for me. I will edit my message. Your solution works. Thank you – Nucore Jun 20 '17 at 16:25

1 Answers1

0

Solution provided by Imo:

day.number.year <- rep(1:360, length.out=33810)
Nucore
  • 107
  • 1
  • 13