time2unit | R Documentation |
Calculate time difference relative to a specified reference time.
time2unit(x, reference, units, ...)
time2sec(x, ...)
time2min(x, ...)
time2hour(x, ...)
time2day(x, ...)
julian(x)
week(x, reference = "Sunday")
x |
Time variable. |
reference |
Reference date, time or day of the week. |
units |
Time units: |
... |
Not used. |
time2sec()
: Calculate time difference in seconds.
time2min()
: Calculate time difference in minutes.
time2hour()
: Calculate time difference in hours.
time2day()
: Calculate time difference in days.
julian()
: Calculate Julian day, i.e. the day of the year relative to January 1st.
week()
: Calculate to in which week of the year a date fall into.
difftime
# Create sample dates:
v <- date(c("2016-07-10", "2016-07-13", "2016-07-16", "2016-08-25", "2016-10-01"))
time2sec(v) # Number of seconds relative to default Jan 1st, 1970.
time2sec(v, as.POSIXct("1900-01-01")) # Relative to default Jan 1st, 1900.
time2min(v, "1900-01-01")
time2hour(v, "1900-01-01")
time2day(v, "1900-01-01")
# Return the julian day for a set of dates.
julian(v)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.