Find the Difference Between Two Dates in R Programming – julian() Function
Last Updated :
22 Jun, 2020
In R programming, difference between two dates can be determined by using basic function julian()
and passing date object as the parameter in the function. It ignores the leap-seconds.
Syntax: julian(x, origin)
Parameters:
x: represents date object
origin: represents another date object from where difference has to be computed
Example 1:
x <- as.Date ( "2020-06-18" )
origin_date <- as.Date ( "2015-05-01" )
julian (x, origin_date)
|
Output:
[1] 1875
attr(, "origin")
[1] "2015-05-01"
Example 2:
x <- as.Date ( "2020-06-18" )
origin_date <- as.Date ( "1920-06-18" )
julian (x, origin_date)
|
Output:
[1] 36525
attr(, "origin")
[1] "1920-06-18"
Share your thoughts in the comments
Please Login to comment...