forked from se-sic/coronet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parameter to 'construct.ranges' to construct cumulative ranges
Works towards se-sic#265. Signed-off-by: Maximilian Löffler <[email protected]>
- Loading branch information
1 parent
b032bcc
commit 86acadc
Showing
1 changed file
with
10 additions
and
3 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 |
---|---|---|
|
@@ -524,10 +524,11 @@ get.time.period.by.amount = function(start.date, end.date, amount) { | |
#' [default: FALSE] | ||
#' @param raw whether to return pairs of POSIXct objects or strings rather than | ||
#' formatted strings [default: FALSE] | ||
#' @param construct.cumulative whether to construct cumulative ranges [default: FALSE] | ||
This comment has been minimized.
Sorry, something went wrong. |
||
#' | ||
#' @return the constructed ranges, either formatted or raw; the raw ranges are a named list, | ||
#' for which the formatted ranges are the names | ||
construct.ranges = function(revs, sliding.window = FALSE, raw = FALSE) { | ||
construct.ranges = function(revs, sliding.window = FALSE, raw = FALSE, cumulative = FALSE) { | ||
This comment has been minimized.
Sorry, something went wrong.
bockthom
|
||
|
||
## make sure that, at least, two revisions are provided | ||
if (length(revs) < 2) { | ||
|
@@ -544,8 +545,14 @@ construct.ranges = function(revs, sliding.window = FALSE, raw = FALSE) { | |
if (sliding.window) | ||
offset = 2 | ||
|
||
## extract sequences of revisions | ||
seq1 = revs[ 1:(length(revs) - offset) ] | ||
## extract start of ranges | ||
if (cumulative) { | ||
seq1 = rep(revs[1], length(revs) - offset) | ||
} else { | ||
seq1 = revs[ 1:(length(revs) - offset) ] | ||
} | ||
|
||
## extract end of reanges | ||
This comment has been minimized.
Sorry, something went wrong. |
||
if ((offset + 1) <= length(revs)) { | ||
seq2 = revs[ (offset + 1):length(revs) ] | ||
} else { | ||
|
The param is just called "cumulative".