When using R's primitive c
function, combining the current datetime with NULL
gives:
> class(c(NULL,Sys.time()))
[1] "numeric"
But when passing NULL last:
> class(c(Sys.time(),NULL))
[1] "POSIXct" "POSIXt"
Is this intended? The documentation for c
reads:
"The output type is determined from the highest type of the components in the hierarchy NULL < raw < logical < integer < double < complex < character < list < expression." but there is no mention of order being relevant.
Is there a better (more consistent) way to combine objects of class POSIXct
with NULL
into a vector? Or should one always explicitly test for NULL
and handle it as a seperate case?