opcycle <- new("OpenCloseCycle")
## convert to SimpleCycle to change some names
siopcycle <- as(opcycle, "SimpleCycle")
## siopcycle inherits names from opcycle
unitSeason(siopcycle) # "Season"
unitCycle(siopcycle) # "Cycle"
allSeasons(siopcycle) # "Open" "Close"
allSeasons(siopcycle, abb = TRUE) # "O" "C"
allSeasons(siopcycle) <- c("Day", "Night")
allSeasons(siopcycle) # now: "Day" "Night"
## change also abbreviations
allSeasons(siopcycle, abb = TRUE) <- c("D", "N")
allSeasons(siopcycle, abb = TRUE) # now: "D" "N"
seasons <- new("SimpleCycle", 4)
unitSeason(seasons) # "Season"
unitCycle(seasons) # "Cycle"
allSeasons(seasons)
allSeasons(seasons, abb = TRUE)
unitCycle(seasons) <- "Year"
unitCycle(seasons)
allSeasons(seasons) <- c("Winter", "Spring", "Summer", "Autumn")
allSeasons(seasons)
allSeasons(seasons, abb = TRUE) <- c("Win", "Spr", "Sum", "Aut")
allSeasons(seasons, abb = TRUE)
## change autumn to Fall
allSeasons(seasons)[4] <- "Fall"
allSeasons(seasons, abb = TRUE)[4] <- "Fal"
allSeasons(seasons)
allSeasons(seasons, abb = TRUE)
## indexing of cycle objects is equivalent to allSeasons.
seasons[]
seasons[ , abb = TRUE]
seasons[4] <- "Herbst"
seasons
unitCycle(seasons) <- "Jahre"
unitCycle(seasons)
unitSeason(seasons) <- "Jahreszeit"
seasons[] <- c("Winter", "Frueling", "Sommer", "Herbst")
seasons[ , abb = TRUE] <- c("W", "F", "S", "H")
seasons[]
seasons
Run the code above in your browser using DataLab