I was trying to create a sequence of dates using the following code:
seq(from = as.POSIXct("2008-01-10 21:20:00 GMT",
origin = "1970-01-01 00:00:00",
format = "%Y-%m-%d %H:%M:%S"),
by = 1, # Code won't hit the error for by values > 3, successfully run for values >=9
to = as.POSIXct("2198-02-27 08:00:00",
origin = "1970-01-01 00:00:00",
format = "%Y-%m-%d %H:%M:%S"))
# This causes the following R error:
# Error in seq.POSIXt(from = as.POSIXct("2008-01-10 21:20:00 GMT", origin = ”1970-01-01 00:00:00", :
# negative length vectors are not allowed
I accept that I'm doing something a little odd here, essentially trying to create a vector of about 198*365*24*60*60 = 6244128000, but I would in that case simply expect it to to take a long time. Is the error message simply inaccurate?
Having dug a little deeper I found that the error stems from seq.int()
which is used by seq.POSIXt()
(I think the error occurs around line 68 of seq.POSIXt()
). Additionally this code works for "by" values that are greater than 3 (although it does understandably hit memory issues). I managed to get it to complete and provide a sequence for '"by" values greater than or equal to 9.
Thanks for your time. This is my first StackOverflow question so I'm sorry if I've failed to adhere to the etiquette in anyway! All help finding out what is going wrong is greatly appreciated.