File: units.Rd

package info (click to toggle)
hmisc 5.2-5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,044 kB
  • sloc: asm: 28,907; f90: 590; ansic: 415; xml: 160; fortran: 75; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 1,537 bytes parent folder | download | duplicates (2)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
\name{units}
\alias{units}
\alias{units.default}
\alias{units.Surv}
\alias{units<-.default}
\title{
Units Attribute of a Vector  
}
\description{
Sets or retrieves the \code{"units"} attribute of an object.
For \code{units.default} replaces the builtin
version, which only works for time series objects.  If the variable is
also given a \code{label}, subsetting (using \code{[.labelled}) will
retain the \code{"units"} attribute.  For a \code{Surv} object,
\code{units} first looks for an overall \code{"units"} attribute, then
it looks for \code{units} for the \code{time2} variable then for \code{time1}.
When setting \code{"units"}, \code{value} is changed to lower case and any "s" at
the end is removed.
}
\usage{
units(x, \dots)
\method{units}{default}(x, none='', \dots)
\method{units}{Surv}(x, none='', \dots)
\method{units}{default}(x) <- value
}
\arguments{
\item{x}{any object}
\item{\dots}{ignored}
\item{value}{the units of the object, or ""}
\item{none}{value to which to set result if no appropriate attribute is
  found}
}
\value{
the units attribute of x, if any; otherwise, the \code{units} attribute of
the \code{tspar} attribute of \code{x} if any; otherwise the value
\code{none}.  Handling for \code{Surv} objects is different (see above).
}
\seealso{\code{\link{label}}}
\examples{
require(survival)
fail.time <- c(10,20)
units(fail.time) <- "Day"
describe(fail.time)
S <- Surv(fail.time)
units(S)

label(fail.time) <- 'Failure Time'
units(fail.time) <- 'Days'
fail.time

}
\keyword{utilities}
\keyword{interface}