1
2# This R package is free software; you can redistribute it and/or
3# modify it under the terms of the GNU Library General Public
4# License as published by the Free Software Foundation; either
5# version 2 of the License, or (at your option) any later version.
6#
7# This R package is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU Library General Public License for more details.
11#
12# You should have received a copy of the GNU Library General
13# Public License along with this R package; if not, write to the
14# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston,
15# MA  02111-1307  USA
16
17
18################################################################################
19# MEHODS:                   DESCRIPTION:
20#  blockStart                Creates start dates for equally sized blocks
21#  blockEnd                  Creates end dates for equally sized blocks
22################################################################################
23
24# ---------------------------------------------------------------------------- #
25# Roxygen Tags
26#' @export
27# ---------------------------------------------------------------------------- #
28blockStart <-
29    function(x, block = 20)
30{
31    # A function implemented by Diethelm Wuertz
32
33    # Description:
34    #   Computes start dates for numeric blocks of dates
35
36    # Example:
37    #   blockEnd(timeSequence(), block = 30)
38
39    # FUNCTION:
40
41    # Start Dates of Blocks:
42    nx = length(as.character(x))
43    fromIdx = seq(1, nx, by = block)
44    from = x[fromIdx]
45
46    # Return Value:
47    from
48}
49
50
51# ---------------------------------------------------------------------------- #
52# Roxygen Tags
53#' @export
54# ---------------------------------------------------------------------------- #
55blockEnd <-
56    function(x, block = 20)
57{
58    # A function implemented by Diethelm Wuertz
59
60    # Description:
61    #   Computes start dates for numeric blocks of dates
62
63    # Example:
64    #   blockEnd(timeSequence(), block = 30)
65
66    # FUNCTION:
67
68    # End Dates of Blocks:
69    nx = length(as.character(x))
70    fromIdx = seq(1, nx, by = block)
71    toIdx = c(fromIdx[-1]-1, nx)
72    to = x[toIdx]
73
74    # Return Value:
75    to
76}
77
78
79################################################################################
80
81