Skip to contents

Functions and methods fo get names of seasons and related quantities for objects from the cycle, periodic time series classes and other objects for which the concepts are defined.

Usage

unitSeason(x)
unitCycle(x)
seqSeasons(x)
allSeasons(x, abb = FALSE, prefix = "S", ...)

unitSeason ( x, ... ) <- value
unitCycle ( x, ... ) <- value
allSeasons ( x, abb, ... ) <- value

# S4 method for SimpleCycle
allSeasons(x, abb, prefix, ...) <- value

# S4 method for Cyclic
allSeasons(x, abb = FALSE, ...) <- value

Arguments

x

a cycle, time series or other object for which the concept of seasons is defined.

abb

if TRUE give the abbreviated names of the seasons.

prefix

use this prefix for automatically generated names of seasons.

...

further arguments for methods.

value

a character string

Details

The cycle classes, i.e. classes inheriting from class BasicCycle, provide common functionality. In particular, they guarantee that the functions described in this topic are available. These functions work also for the periodic time series classes and may be defined for other classes where they make sense.

Author

Georgi N. Boshnakov

Methods

Methods for allSeasons():

signature(x = "BasicCycle", abb = "ANY")

signature(x = "DayWeekCycle", abb = "logical")

signature(x = "DayWeekCycle", abb = "missing")

signature(x = "FiveDayWeekCycle", abb = "logical")

signature(x = "FiveDayWeekCycle", abb = "missing")

signature(x = "MonthYearCycle", abb = "logical")

signature(x = "MonthYearCycle", abb = "missing")

signature(x = "OpenCloseCycle", abb = "logical")

signature(x = "OpenCloseCycle", abb = "missing")

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

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

signature(x = "SimpleCycle", abb = "ANY")

signature(x = "Cyclic", abb = "ANY")

signature(x = "Every30MinutesCycle", abb = "logical")

signature(x = "Every30MinutesCycle", abb = "missing")

signature(x = "VirtualPeriodicModel", abb = "ANY")

Examples

opcycle <- new("OpenCloseCycle")
## convert to SimpleCycle to change some names
siopcycle <- as(opcycle, "SimpleCycle")
## siopcycle inherits names from opcycle
unitSeason(siopcycle)             # "Season"
#> [1] "OpenOrClose"
unitCycle(siopcycle)              # "Cycle"
#> [1] "HalfDay"
allSeasons(siopcycle)             # "Open"  "Close"
#> [1] "Open"  "Close"
allSeasons(siopcycle, abb = TRUE) # "O" "C"
#> [1] "O" "C"

allSeasons(siopcycle) <- c("Day", "Night")
allSeasons(siopcycle) # now: "Day"   "Night"
#> [1] "Day"   "Night"
## change also abbreviations
allSeasons(siopcycle, abb = TRUE) <- c("D", "N")
allSeasons(siopcycle, abb = TRUE) # now: "D" "N"
#> [1] "D" "N"

seasons <- new("SimpleCycle", 4)
unitSeason(seasons)             # "Season"
#> [1] "Season"
unitCycle(seasons)              # "Cycle"
#> [1] "Cycle"
allSeasons(seasons)
#> [1] "Season_1" "Season_2" "Season_3" "Season_4"
allSeasons(seasons, abb = TRUE) 
#> [1] "S1" "S2" "S3" "S4"

unitCycle(seasons) <- "Year"
unitCycle(seasons)
#> [1] "Year"
allSeasons(seasons) <- c("Winter", "Spring", "Summer", "Autumn")
allSeasons(seasons)
#> [1] "Winter" "Spring" "Summer" "Autumn"
allSeasons(seasons, abb = TRUE) <- c("Win", "Spr", "Sum", "Aut")
allSeasons(seasons, abb = TRUE)
#> [1] "Win" "Spr" "Sum" "Aut"

## change autumn to Fall
allSeasons(seasons)[4] <- "Fall"
allSeasons(seasons, abb = TRUE)[4] <- "Fal"
allSeasons(seasons)
#> [1] "Winter" "Spring" "Summer" "Fall"  
allSeasons(seasons, abb = TRUE)
#> [1] "Win" "Spr" "Sum" "Fal"

## indexing of cycle objects is equivalent to allSeasons.
seasons[]
#> [1] "Winter" "Spring" "Summer" "Fall"  
seasons[ , abb = TRUE]
#> [1] "Win" "Spr" "Sum" "Fal"

seasons[4] <- "Herbst"
seasons
#> Object from class 'SimpleCycle'
#> Number of seasons: 4 
#> Seasons: Winter Spring Summer Herbst 
#> Abbreviated: Win Spr Sum Fal 

unitCycle(seasons) <- "Jahre"
unitCycle(seasons)
#> [1] "Jahre"
unitSeason(seasons) <- "Jahreszeit"
seasons[] <- c("Winter", "Frueling", "Sommer", "Herbst")
seasons[ , abb = TRUE] <- c("W", "F", "S", "H")
seasons[]
#> [1] "Winter"   "Frueling" "Sommer"   "Herbst"  
seasons
#> Object from class 'SimpleCycle'
#> Number of seasons: 4 
#> Seasons: Winter Frueling Sommer Herbst 
#> Abbreviated: W F S H