asDifftime {ThomasJeffersonUniv} | R Documentation |
Create Time Differences, Extended
Description
To create difftime object
with additional time units 'months'
and 'years'
.
Usage
asDifftime(
tim,
units = names(timeUnits()),
negative_do = stop(sQuote(deparse1(substitute(tim))), " has negative value!"),
...
)
Arguments
tim |
numeric or difftime object, similar usage as in function as.difftime |
units |
character scalar,
similar usage as in function as.difftime,
but with additional options |
negative_do |
exception handling
if input |
... |
additional parameters, currently not in use |
Details
Function asDifftime improves function as.difftime in terms that
-
If input
tim
is a difftime object, function units_difftime<- is called and the unit oftim
is updated. In function as.difftime,tim
is returned directly, i.e., parameterunits
is ignored -
Time units
'months'
and'years'
are supported, in addition to'secs'
,'mins'
,'hours'
,'days'
,'weeks'
supported in function as.difftime. Moreover, partial matching (via function match.arg) is allowed, while function as.difftime requires exact matching. -
End user may choose to stop if
tim
has negative values. Function as.difftime does not check for negativetim
.
Value
Function asDifftime returns a difftime object.
Note
Potential name clash with function as_difftime