0

I have a list of double that I want to convert to date of any format possible.

time = seq(2008,2017,length.out = 300)

I cannot use as.Date(time) directly cause the results will be starting from 1970.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Jiaying Gu
  • 1
  • 1
  • 1
  • Relevant - http://stackoverflow.com/questions/26965699/converting-date-in-year-decimal-form-in-r and http://stackoverflow.com/questions/29697436/how-to-convert-decimal-date-format-e-g-2011-580-to-normal-date-format/32468790 – thelatemail May 02 '17 at 22:45

1 Answers1

1

Invert the order: first convert the start and end point to dates, then use seq to interpolate between them.

Using the ‹lubridate› package:

seq(ymd('2008-01-01'), ymd('2017-01-01'), length.out = 300)

(This is using the first of January as the start and end date; in your code it’s ambiguous what you wanted to use, and indeed one good reason why it can’t work like that.)

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214