The Following function, orginal from R - convert POSIXct to fraction of julian day is the function I would like to change.
julian_conv <- function(x) {
if (is.na(x)) {
return(NA)
}
else {
j <-julian(x, origin = as.POSIXlt(paste0(format(x, "%Y"),'-01-01')))
temp <- unclass(j)
return(temp[1] + 1)
}
}
The function turns a date into julian days. Example:
date <- as.POSIXct('2006-12-12 12:00:00')
julian_conv(date)
#[1] 345.5
Is it possible to change the function that it can change more than one date at the time? For example the following dates:
date <- as.POSIXct(c('2006-12-12 13:00:00', '2013-12-12 12:00:00', '2020-12-12 12:00:00'))