sh_round | R Documentation |
sh_floor()
takes a jdate
object and rounds it down to the previous unit of time.
sh_ceiling()
takes a jdate
object and rounds it up to the next unit of time.
sh_round()
takes a jdate
object and and rounds it up or down, depending on what is closer.
For dates which are exactly halfway between two consecutive units, the convention is to round up.
sh_round(x, unit = NULL, ...)
sh_floor(x, unit = NULL, ...)
sh_ceiling(x, unit = NULL, ...)
x |
A vector of |
unit |
A scalar character, containing a date unit or a multiple of a unit.
Valid date units are |
... |
These dots are for future extensions and must be empty. |
A vector of jdate
objects with the same length as x.
lubridate::round_date()
x <- jdate("1402-12-15")
sh_floor(x, "year")
sh_floor(x, "2 months")
sh_ceiling(x, "year")
sh_round(x, "year")
sh_round(x, "week") == sh_floor(x, "week")
sh_round(x + 1, "week") == sh_ceiling(x, "week")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.