| t_unit | R Documentation |
t_unit method returns time unit of time difference object
as a character value, either in short form (most often single letter,
code used internally) or long form (name).
units method for tdiff objects is equivalent
to t_unit with x argument only.
t_unit(x, long = TRUE, valid = FALSE)
## S3 method for class 'tdiff'
t_unit(x, long = TRUE, valid = FALSE)
## S3 method for class 'difftime'
t_unit(x, long = TRUE, valid = FALSE)
## S3 method for class 'tdiff'
units(x)
x |
an object of |
long |
a logical value, if |
valid |
a logical value, if |
Time differences (for example differences between date-time indices) are internally represented as number of seconds. However, the returned time unit is automatically determined based on the resolution of the argument. If all time differences are full hours or full minutes, appropriate unit is returned, see Examples. For time differences that contain zeros and missing values only, returned unit is a second.
A character value.
tdiff, ti_type.
(x <- as.tdiff(1, "y"))
t_unit(x)
t_unit(x, FALSE)
(x <- as.tdiff(1, "q"))
t_unit(x)
t_unit(x, FALSE)
(x <- as.tdiff(1, "m"))
t_unit(x)
t_unit(x, FALSE)
(x <- as.tdiff(1, "w"))
t_unit(x)
t_unit(x, FALSE)
(x <- as.tdiff(1, "d"))
t_unit(x)
t_unit(x, FALSE)
(x <- as.tdiff(1, "h"))
t_unit(x)
t_unit(x, FALSE)
(x <- as.tdiff(1, "min"))
t_unit(x)
t_unit(x, FALSE)
(x <- as.tdiff(1, "s"))
t_unit(x)
t_unit(x, FALSE)
# automatic unit determination
(x <- as.tdiff(600, "s")) # ten minutes
t_unit(x)
t_unit(x, FALSE)
(x <- as.tdiff(7200, "s")) # two hours
t_unit(x)
t_unit(x, FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.