GetUnitText: Format a nice time units for labels in graphs

Description Usage Arguments Value Author(s) See Also Examples

Description

This is an internal function called by some plot() methods. Considering the time series 'units' attribute and the frequency of the observations in the series, the function returns a string with a pertinent time unit. For instance, if the unit is 'years' and the frequency is 12, then data are monthly sampled and GetUnitText() returns the string "months"

Usage

1
GetUnitText(series)

Arguments

series

a regular time series (a 'rts' object in Splus, or a 'ts' object in R)

Value

a string with the best time unit for graphs

Author(s)

Philippe Grosjean (phgrosjean@sciviews.org), Frédéric Ibanez (ibanez@obs-vlfr.fr)

See Also

daystoyears, yearstodays

Examples

1
2
3
4
5
6
7
timeser <- ts(1:24, frequency=12)           # 12 observations per year
if (exists("is.R") && is.function(is.R) && is.R()) {  # We are in R
attr(timeser, "units") <- "years"           # time in years for 'ts' object
} else {                                              # We are in Splus
attr(attr(timeser, "tspar"), "units") <- "years" # Idem for Splus 'rts' object
}
GetUnitText(timeser)                        # formats unit (1/12 year=months)


pastecs documentation built on May 19, 2017, 8:33 p.m.
Search within the pastecs package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.