1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
units <- function(x, ...)
UseMethod("units")
"units<-.default" <- function(x, value)
{
# value <- sub('s$', '', tolower(value))
attr(x, "units") <- value
x
}
units.default <- function(x, none='', ...)
{
lab <- attr(x, "units")
if(is.null(lab))
lab <- attr(attr(x,'tspar'),'units')
if(is.null(lab))
lab <- none
lab
}
units.Surv <- function(x, none='', ...)
{
at <- attributes(x)
un <- at$units
ia <- at$inputAttributes
if(! length(un) && length(ia)) {
un <- ia$time2$units
if(! length(un)) un <- ia$time$units
}
if(! length(un)) un <- none
un
}
|