Learn R Programming

mondate (version 0.9.10.01)

timeunits-methods: Methods to Access 'timeunits' Property

Description

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

Usage

## S3 method for class 'mondate':
timeunits(x)
## S3 method for class 'ANY':
timeunits(x)
## S3 method for class 'mondate':
timeunits(x)<-value
## S3 method for class 'mondate':
mondateTimeunits(x)
## S3 method for class 'ANY':
mondateTimeunits(x)
## S3 method for class 'mondate':
mondateTimeunits(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

Examples

Run this code
x<-mondate("2010-6-30") # The middle of 2010
mondateTimeunits(x)     # "months"
y<-x+12                 # One year (12 months) later.
mondateTimeunits(y)     # "months"
y-x                     # Result is 12 months
mondateTimeunits(y) <- "years"
y-x                     # Result is 1 year, with a warning because 
                        # x@timeunits != y@timeunits. Units of result
                        # comes from the first argument.
mondateTimeunits(y) <- "days"
suppressWarnings(y-x)   # Result is 365 days -- warning suppressed

Run the code above in your browser using DataLab