as.year: Year vectors

Description Usage Arguments Details Value Examples

View source: R/as.year.R

Description

Creates or coerces objects of type year.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
as.year(x)

## S3 method for class 'Date'
as.year(x)

## Default S3 method:
as.year(x)

is.year(x)

## S3 method for class 'year'
a - b

width.year(x)

Arguments

x

object to be coerced or tested

a, b

years to be added or subtracted

Details

The year class also inherits methods from the character class but not from numeric. (It does not make any sence to, for example, multiply two years with each other). There are however methods for subtraction and it is also possible to add a integer to a year etcetera.

Value

Vector of class year and "AsIs" (see function I).

Examples

1
2
3
as.year("2012")
as.year(Sys.Date())
rccmisc::width(c(2012, 2014))

Example output

[1] "2012"
[1] "2020"
[1] 3

rccdates documentation built on May 2, 2019, 1:46 p.m.