timeunits-methods: Methods to Access 'timeunits' Property

Description Usage Arguments Note Examples

Description

Methods to get and set the timeunits value of a mondate.

Usage

1
2
3
4
5
6
## S4 method for signature 'mondate'
timeunits(x)
## S4 method for signature 'ANY'
timeunits(x)
## S4 replacement method for signature 'mondate'
timeunits(x)<-value

Arguments

x

a mondate.

value

For the "get" method, a character string indicating the units with which to measure time as a result of operations on a mondate. Choices are currently

  1. "months"

  2. "years"

  3. "days"

If x is not a mondate, the "get" value returned is NULL.

Note

The mondateTimeunits versions have been deprecated.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
x <- mondate("2010-6-30") # The middle of 2010
timeunits(x)              # "months"
y <- x + 12               # One year (12 months) later.
timeunits(y)              # "months"
y - x                     # Result is 12 months
timeunits(y) <- "years"
y - x                     # Result is 1 year, with a warning because 
                          # x@timeunits != y@timeunits. Units of result
                          # comes from the first argument.
timeunits(y) <- "days"
suppressWarnings(y - x)   # Result is 365 days -- warning suppressed

mondate documentation built on Jan. 29, 2021, 5:06 p.m.