Hmisc (version 3.0-12)

units: Units Attribute of a Vector

Description

Sets or retrieves the "units" attribute of an object. For units.default replaces the builtin version, which only works for time series objects. If the variable is also given a label, subsetting (using [.labelled) will retain the "units" attribute. For S-Plus 6 which uses version 4 of the S language, the latter does not work.

Usage

units(x, ...)
## S3 method for class 'default':
units(x, none='', \dots)
units(x) <- value

Arguments

x
any object
...
ignored
value
the units of the object, or ""
none
value to which to set result if no appropriate attribute is found

Value

  • the units attribute of x, if any; otherwise, the units attribute of the tspar attribute of x if any; otherwise the value none

See Also

label

Examples

Run this code
fail.time <- c(10,20)
units(fail.time) <- "Day"
describe(fail.time)
label(fail.time) <- 'Failure Time'
fail.time
f <- cph(Surv(fail.time, event) ~ xx)
plot(xx,xx2,xlab=paste(label(xx),", ",units(xx),"s",sep=""))

Run the code above in your browser using DataCamp Workspace