Search code examples
rvectortime-seriesrep

Filling a NA-Vector multiple times with the same vector [day number of the year]


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.


Solution

  • Solution provided by Imo:

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