I have a dataframe with Julian dates in the format:
2455764.833333
2455764.875000
2455764.916667
dput <- structure(list(date = structure(c(2L, 1L, 1L, 1L, 1L), .Label = c("",
"2011-07-21T20:00:00"), class = "factor"), longitude = structure(c(1L,
1L, 1L, 1L, 1L), .Label = "-6.396", class = "factor"), latitude = structure(c(1L,
1L, 1L, 1L, 1L), .Label = "56.6283", class = "factor"), julian = structure(1:5, .Label = c("2455764.833333",
"2455764.875000", "2455764.916667", "2455764.958333", "2455765.000000"
), class = "factor"), record_no = 1:5, temp = structure(c(1L,
3L, 2L, 4L, 5L), .Label = c("12.414", "12.463", "12.515", "12.618",
"12.767"), class = "factor"), depth = structure(c(1L, 1L, 1L,
1L, 1L), .Label = " 34.00", class = "factor")), row.names = c(NA,
5L), class = "data.frame")
Online Julian date converter converts correctly (for the above it is 22 July 2011) - but I need the time elements from the details after the decimal points in addition to the date.
The origin is January 1, 4713 BC. I've read that as.Date doesn't handle BC dates. If I convert $julian to numeric it drops the data after the decimal point.
I've tried various suggestions from on here but haven't found any that work with the BC origin AND the time element.
tiree$date2 <- as.Date(tiree$julian, origin = structure(-2440588, class = "Date"))
from Convert Julian Date to Date - R gives me Error in charToDate(x) : character string is not in a standard unambiguous format (edit: as per suggestion to convert to numeric the error is removed but output is incorrect).
Any suggestions welcomed - I think I am probably missing something obvious!
Many thanks