BuiltinCycle-class: Class '"BuiltinCycle"' and its subclasses in package 'pcts'

BuiltinCycle-classR Documentation

Class "BuiltinCycle" and its subclasses in package 'pcts'

Description

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".

Currently, the following builtin classes are defined:

Name Description nSeasons
"DayWeekCycle" weekdays 7
"QuarterYearCycle" quarters in a year 4
"MonthYearCycle" months in a year 12
"Every30MinutesCycle" half-hour intervals in a day 48
"OpenCloseCycle" start/end of a working day 2

There is also a class "FiveDayWeekCycle" but it is deprecated and will be removed in the near future. Use BuiltinCycle(5) to create objects with equivalent functionality.

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"): ...

The functions to extract properties from objects from the builtin cycle classes have identical signatures (except for the name of the class). For example, for "QuarterYearCycle" the methods are as follows:

allSeasons

signature(x = "QuarterYearCycle", abb = "logical"): ...

allSeasons

signature(x = "QuarterYearCycle", abb = "missing"): ...

nSeasons

signature(object = "QuarterYearCycle"): ...

unitCycle

signature(x = "QuarterYearCycle"): ...

unitSeason

signature(x = "QuarterYearCycle"): ...

The methods for the remaining builtin classes are the same with "QuarterYearCycle" replaced suitably.

Author(s)

Georgi N. Boshnakov

See Also

BuiltinCycle, pcCycle for creation of cycle objects and extraction of cycle part of time series,

class PartialCycle for creating variants of the builtin classes, e.g., 5-day weeks.

BareCycle-class, SimpleCycle-class,

Examples

## class "DayWeekCycle"
dwcycle <- BuiltinCycle(7) # new("DayWeekCycle")

unitSeason(dwcycle)
unitCycle(dwcycle)

allSeasons(dwcycle)
dwcycle[] # same

allSeasons(dwcycle, abb = TRUE)
dwcycle[ , abb = TRUE] # same

dwcycle[2]
dwcycle[2, abb = TRUE]

seqSeasons(dwcycle)

## start the week on Sunday
dws <- BuiltinCycle(7, first = 7) # new("DayWeekCycle", first = 7)
dws[1] # "Sunday"
allSeasons(dws)

## class "Every30MinutesCycle"
cyc48 <- BuiltinCycle(48) # new("Every30MinutesCycle")
nSeasons(cyc48)
allSeasons(cyc48)

## class "FiveDayWeekCycle" is deprecated, use the equivalent:
fdcycle <- BuiltinCycle(5)

unitSeason(fdcycle)
unitCycle(fdcycle)

allSeasons(fdcycle)
fdcycle[] # same

allSeasons(fdcycle, abb = TRUE)
fdcycle[ , abb = TRUE] # same

fdcycle[2]
fdcycle[2, abb = TRUE]

seqSeasons(fdcycle)

## class "MonthYearCycle"
mycycle <- BuiltinCycle(12) # new("MonthYearCycle")

unitSeason(mycycle)
unitCycle(mycycle)

allSeasons(mycycle)
mycycle[ ] # same

allSeasons(mycycle, , abb = TRUE)
mycycle[ , abb = TRUE] # same

mycycle[2]
mycycle[2, abb = TRUE]

seqSeasons(mycycle)

## class "OpenCloseCycle"
opcycle <- new("OpenCloseCycle")

unitSeason(opcycle)
unitCycle(opcycle)

allSeasons(opcycle)
opcycle[ , abb = FALSE] # same

allSeasons(opcycle, abb = FALSE)
opcycle[] # same

opcycle[2]
opcycle[2, abb = TRUE]

seqSeasons(opcycle)

## class "QuarterYearCycle"
qycycle <- new("QuarterYearCycle")

unitSeason(qycycle)
unitCycle(qycycle)

allSeasons(qycycle)
qycycle[] # same

allSeasons(qycycle, abb = TRUE)
qycycle[ , abb = TRUE] # same

qycycle[2]
qycycle[2, abb = TRUE]

seqSeasons(qycycle)

GeoBosh/pcts documentation built on Dec. 8, 2023, 9:57 p.m.