as_yearqtr() and as_yearmon() are included for interoperability with zoo::yearqtr(), an alternative year-quarter format that is based on a decimal representation as opposed to dint's integer representation of year-quarters. as_yearweek() follows a similar idea, but there is no corresponding S3 class in zoo. These functions were included for cases where you need a continuous representation of date_xx objects other then base::Date() (for example, they are used by scale_date_xx)

as_yearqtr(x)

# S3 method for date_yq
as_yearqtr(x)

# S3 method for yearqtr
as_yearqtr(x)

as_yearmon(x)

# S3 method for date_ym
as_yearmon(x)

# S3 method for yearmon
as_yearmon(x)

as_yearweek(x)

# S3 method for date_yw
as_yearweek(x)

# S3 method for yearweek
as_yearweek(x)

Arguments

x

any R object

Value

a zoo::yearqtr, zoo::yearmon or dint::yearweek vector.

Examples

q <- date_yq(2016, 1:4) as.numeric(q)
#> [1] 20161 20162 20163 20164
qzoo <- as_yearqtr(q) as.numeric(qzoo)
#> [1] 2016.00 2016.25 2016.50 2016.75
m <- date_ym(2016, 1:12) as.numeric(m)
#> [1] 201601 201602 201603 201604 201605 201606 201607 201608 201609 201610 #> [11] 201611 201612
mzoo <- as_yearmon(m) as.numeric(mzoo)
#> [1] 2016.000 2016.083 2016.167 2016.250 2016.333 2016.417 2016.500 2016.583 #> [9] 2016.667 2016.750 2016.833 2016.917
w <- date_yw(2016, 1:52) as.numeric(w)
#> [1] 201601 201602 201603 201604 201605 201606 201607 201608 201609 201610 #> [11] 201611 201612 201613 201614 201615 201616 201617 201618 201619 201620 #> [21] 201621 201622 201623 201624 201625 201626 201627 201628 201629 201630 #> [31] 201631 201632 201633 201634 201635 201636 201637 201638 201639 201640 #> [41] 201641 201642 201643 201644 201645 201646 201647 201648 201649 201650 #> [51] 201651 201652
wzoo <- as_yearweek(w) as.numeric(wzoo)
#> [1] 2016.000 2016.019 2016.038 2016.057 2016.075 2016.094 2016.113 2016.132 #> [9] 2016.151 2016.170 2016.189 2016.208 2016.226 2016.245 2016.264 2016.283 #> [17] 2016.302 2016.321 2016.340 2016.358 2016.377 2016.396 2016.415 2016.434 #> [25] 2016.453 2016.472 2016.491 2016.509 2016.528 2016.547 2016.566 2016.585 #> [33] 2016.604 2016.623 2016.642 2016.660 2016.679 2016.698 2016.717 2016.736 #> [41] 2016.755 2016.774 2016.792 2016.811 2016.830 2016.849 2016.868 2016.887 #> [49] 2016.906 2016.925 2016.943 2016.962