Class "BuiltinCycle"
and its subclasses in package 'pcts'
BuiltinCycle-class.Rd
Class "BuiltinCycle"
and its subclasses in package 'pcts'.
Objects from the Class
Class "BuiltinCycle"
is a virtual Class: no objects may be
created from it. Class "BuiltinCycle"
has several built-in
cycle subclasses. Objects from the subclasses can be created by calls
of the form new("className", first, ...)
, where
"className"
is the name of the subclass. The optional argument
first
can be used to designate a season to be considered first
in the cycle, by default the first.
The function BuiltinCycle
provides a more convenient way
to generate objects from subclasses of class
"BuiltinCycle"
. Its argument is the number of seasons.
These classes are effectively unmodifiable, but the user can convert them to other cycle classes, e.g. class "SimpleCycle", and adapt as needed.
The subclasses of "BuiltinCycle"
have definitions for all
methods promised by its superclass "BasicCycle"
.
Slots
The class "BuiltinCycle"
and its subclasses have a single
common slot:
first
:Object of class
"integer"
, the index of the season to be treated as the first in a cycle.
Extends
Class "BuiltinCycle"
extends class
"BasicCycle"
, directly.
Classes "DayWeekCycle"
, "Every30MinutesCycle"
,
"FiveDayWeekCycle"
, "OpenCloseCycle"
and
"QuarterYearCycle"
extend:
Class "BuiltinCycle"
, directly.
Class "BasicCycle"
, by class "BuiltinCycle", distance 2.
Methods
Functions with methods for this class:
- coerce
signature(from = "BuiltinCycle", to = "BareCycle")
: ...- coerce
signature(from = "BuiltinCycle", to = "SimpleCycle")
: ...- initialize
signature(.Object = "BuiltinCycle")
: ...- show
signature(object = "BuiltinCycle")
: ...
% Class \code{"DayWeekCycle"}
- allSeasons
signature(x = "DayWeekCycle", abb = "logical")
- allSeasons
signature(x = "DayWeekCycle", abb = "missing")
- nSeasons
signature(object = "DayWeekCycle")
- unitCycle
signature(x = "DayWeekCycle")
- unitSeason
signature(x = "DayWeekCycle")
% Class \code{"Every30MinutesCycle"}
- allSeasons
signature(x = "Every30MinutesCycle", abb = "logical")
: ...- allSeasons
signature(x = "Every30MinutesCycle", abb = "missing")
: ...- nSeasons
signature(object = "Every30MinutesCycle")
: ...- unitCycle
signature(x = "Every30MinutesCycle")
: ...- unitSeason
signature(x = "Every30MinutesCycle")
: ...
% \code{"FiveDayWeekCycle"}
- allSeasons
signature(x = "FiveDayWeekCycle", abb = "logical")
: ...- allSeasons
signature(x = "FiveDayWeekCycle", abb = "missing")
: ...- nSeasons
signature(object = "FiveDayWeekCycle")
: ...- unitCycle
signature(x = "FiveDayWeekCycle")
: ...- unitSeason
signature(x = "FiveDayWeekCycle")
: ...
% \code{MonthYearCycle}
- allSeasons
signature(x = "MonthYearCycle", abb = "logical")
: ...- allSeasons
signature(x = "MonthYearCycle", abb = "missing")
: ...- nSeasons
signature(object = "MonthYearCycle")
: ...- unitCycle
signature(x = "MonthYearCycle")
: ...- unitSeason
signature(x = "MonthYearCycle")
: ...
% \code{"OpenCloseCycle"}
- allSeasons
signature(x = "OpenCloseCycle", abb = "logical")
: ...- allSeasons
signature(x = "OpenCloseCycle", abb = "missing")
: ...- nSeasons
signature(object = "OpenCloseCycle")
: ...- unitCycle
signature(x = "OpenCloseCycle")
: ...- unitSeason
signature(x = "OpenCloseCycle")
: ...
% \code{"QuarterYearCycle"}
- allSeasons
signature(x = "QuarterYearCycle", abb = "logical")
: ...- allSeasons
signature(x = "QuarterYearCycle", abb = "missing")
: ...- nSeasons
signature(object = "QuarterYearCycle")
: ...- unitCycle
signature(x = "QuarterYearCycle")
: ...- unitSeason
signature(x = "QuarterYearCycle")
: ...
See also
BuiltinCycle
,
pcCycle
for creation of cycle objects and extraction of
cycle part of time series,
BareCycle-class
,
SimpleCycle-class
,
Examples
## class "DayWeekCycle"
dwcycle <- BuiltinCycle(7) # new("DayWeekCycle")
unitSeason(dwcycle)
#> [1] "Day"
unitCycle(dwcycle)
#> [1] "Week"
allSeasons(dwcycle)
#> [1] "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"
#> [7] "Sunday"
dwcycle[] # same
#> [1] "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"
#> [7] "Sunday"
allSeasons(dwcycle, abb = TRUE)
#> [1] "Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun"
dwcycle[ , abb = TRUE] # same
#> [1] "Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun"
dwcycle[2]
#> [1] "Tuesday"
dwcycle[2, abb = TRUE]
#> [1] "Tue"
seqSeasons(dwcycle)
#> [1] 1 2 3 4 5 6 7
## start the week on Sunday
dws <- BuiltinCycle(7, first = 7) # new("DayWeekCycle", first = 7)
dws[1] # "Sunday"
#> [1] "Sunday"
allSeasons(dws)
#> [1] "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
#> [7] "Saturday"
## class "Every30MinutesCycle"
cyc48 <- BuiltinCycle(48) # new("Every30MinutesCycle")
nSeasons(cyc48)
#> [1] 48
allSeasons(cyc48)
#> [1] "00:30" "01:00" "01:30" "02:00" "02:30" "03:00" "03:30" "04:00" "04:30"
#> [10] "05:00" "05:30" "06:00" "06:30" "07:00" "07:30" "08:00" "08:30" "09:00"
#> [19] "09:30" "10:00" "10:30" "11:00" "11:30" "12:00" "12:30" "13:00" "13:30"
#> [28] "14:00" "14:30" "15:00" "15:30" "16:00" "16:30" "17:00" "17:30" "18:00"
#> [37] "18:30" "19:00" "19:30" "20:00" "20:30" "21:00" "21:30" "22:00" "22:30"
#> [46] "23:00" "23:30" "00:00"
## class "FiveDayWeekCycle" is deprecated, use the equivalent:
fdcycle <- BuiltinCycle(5)
unitSeason(fdcycle)
#> [1] "Day"
unitCycle(fdcycle)
#> [1] "Week"
allSeasons(fdcycle)
#> [1] "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
fdcycle[] # same
#> [1] "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
allSeasons(fdcycle, abb = TRUE)
#> [1] "Mon" "Tue" "Wed" "Thu" "Fri"
fdcycle[ , abb = TRUE] # same
#> [1] "Mon" "Tue" "Wed" "Thu" "Fri"
fdcycle[2]
#> [1] "Tuesday"
fdcycle[2, abb = TRUE]
#> [1] "Tue"
seqSeasons(fdcycle)
#> [1] 1 2 3 4 5
## class "MonthYearCycle"
mycycle <- BuiltinCycle(12) # new("MonthYearCycle")
unitSeason(mycycle)
#> [1] "Month"
unitCycle(mycycle)
#> [1] "Year"
allSeasons(mycycle)
#> [1] "January" "February" "March" "April" "May" "June"
#> [7] "July" "August" "September" "October" "November" "December"
mycycle[ ] # same
#> [1] "January" "February" "March" "April" "May" "June"
#> [7] "July" "August" "September" "October" "November" "December"
allSeasons(mycycle, , abb = TRUE)
#> [1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"
mycycle[ , abb = TRUE] # same
#> [1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"
mycycle[2]
#> [1] "February"
mycycle[2, abb = TRUE]
#> [1] "Feb"
seqSeasons(mycycle)
#> [1] 1 2 3 4 5 6 7 8 9 10 11 12
## class "OpenCloseCycle"
opcycle <- new("OpenCloseCycle")
unitSeason(opcycle)
#> [1] "OpenOrClose"
unitCycle(opcycle)
#> [1] "HalfDay"
allSeasons(opcycle)
#> [1] "Open" "Close"
opcycle[ , abb = FALSE] # same
#> [1] "Open" "Close"
allSeasons(opcycle, abb = FALSE)
#> [1] "Open" "Close"
opcycle[] # same
#> [1] "Open" "Close"
opcycle[2]
#> [1] "Close"
opcycle[2, abb = TRUE]
#> [1] "C"
seqSeasons(opcycle)
#> [1] 1 2
## class "QuarterYearCycle"
qycycle <- new("QuarterYearCycle")
unitSeason(qycycle)
#> [1] "Quarter"
unitCycle(qycycle)
#> [1] "Year"
allSeasons(qycycle)
#> [1] "Quarter_1" "Quarter_2" "Quarter_3" "Quarter_4"
qycycle[] # same
#> [1] "Quarter_1" "Quarter_2" "Quarter_3" "Quarter_4"
allSeasons(qycycle, abb = TRUE)
#> [1] "Q1" "Q2" "Q3" "Q4"
qycycle[ , abb = TRUE] # same
#> [1] "Q1" "Q2" "Q3" "Q4"
qycycle[2]
#> [1] "Quarter_2"
qycycle[2, abb = TRUE]
#> [1] "Q2"
seqSeasons(qycycle)
#> [1] 1 2 3 4