-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved all the new helper functions required for generating breaks and…
… scales to the appropriate files, added documentation for as_yearqtr, added round, ceiling, floor for all date_xx
- Loading branch information
Showing
18 changed files
with
243 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Type: Package | ||
Package: dint | ||
Title: A Toolkit for Year-Quarter, Year-Month and Year-Isoweek Dates | ||
Version: 2.0.0.9000 | ||
Version: 2.0.0.9001 | ||
Authors@R: person("Stefan", "Fleck", email = "[email protected]", role = c("aut", "cre")) | ||
Maintainer: Stefan Fleck <[email protected]> | ||
Description: | ||
|
@@ -20,6 +20,7 @@ Suggests: | |
lubridate, | ||
rmarkdown, | ||
testthat, | ||
zoo, | ||
covr | ||
VignetteBuilder: knitr | ||
Encoding: UTF-8 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#' For compat with zoo | ||
#' | ||
#' Internaly used constructor. If you use zoo, please use [zoo::yearqtr()] | ||
#' instead | ||
#' | ||
#' @param x a vector with dates in the form 2000.0 for Q1, 2000.25 for Q2, usw | ||
#' @noRd | ||
#' | ||
yearqtr <- function(x){ | ||
assert(all((x %% 1) %in% c(0, 0.25, 0.5, 0.75))) | ||
structure(x, class = c("yearqtr", "numeric")) | ||
} | ||
|
||
|
||
|
||
|
||
#' Coerce to zoo yeartqr objects | ||
#' | ||
#' `as_yearqtr()` is included for interoperatility 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. | ||
#' | ||
#' @param x any \R object | ||
#' | ||
#' @return a [zoo::yearqtr] vector | ||
#' @export | ||
#' | ||
#' @examples | ||
#' | ||
#' x <- date_yq(2016, 2) | ||
#' as_yearqtr(x) | ||
#' | ||
as_yearqtr <- function(x){ | ||
UseMethod("as_yearqtr") | ||
} | ||
|
||
|
||
|
||
|
||
#' @rdname as_yearqtr | ||
#' @export | ||
as_yearqtr.date_yq <- function(x){ | ||
yearqtr(get_year(x) + (get_quarter(x) - 1L) / 4) | ||
} | ||
|
||
|
||
|
||
#' @rdname as_yearqtr | ||
as_yearqtr.yearqtr <- function(x){ | ||
x | ||
} | ||
|
||
|
||
|
||
|
||
# zoo dynamic s3 mehtods -------------------------------------------------- | ||
|
||
# dynamically registered if zoo is installed | ||
as.yearqtr.date_yq <- as_yearqtr.date_yq |
Oops, something went wrong.