Convert double to date
Hi all, what appeared to be an easy task turns into a mystery - at least judged from my previous experience with other languages. I queried some historical data from an exchange and stored into a double array a_fetchdata:
typeof(a_fetchdata)
[1] "double"
a_fetchdata[1,1:2]
NGFJ6.Open NGFJ6.High 2016-02-09 07:30:00 0.2897 0.2897 #### Please note above result has no header for the date/time column My goal is to take the date, deduct one day and arrive at "2016-02-08". So I tried converting into a date (with paste/without paste)
as.Date(c(strhead(paste(a_fetchdata[1,0]),10)),"%Y-%m-%d")
or strptime(c(a_fetchdata[1,0]),format="%Y%m%d") But I keep running into the same error message: *Error in dimnames(cd) <- list(as.character(index(x)), colnames(x)) : 'dimnames' applied to non-array* Can anyone please shed some light on that? Many thanks in advance, Peter