xtfrm
Auxiliary Function for Sorting and Ranking

Description

Generic auxiliary function to create a numeric vector sorted in the same order as input object.

Usage

xtfrm(x)
## Default S3 method:
xtfrm(x)
## S3 method for class 'AsIs':
xtfrm(x)
## S3 method for class 'Date':
xtfrm(x)
## S3 method for class 'difftime':
xtfrm(x)
## S3 method for class 'factor':
xtfrm(x)
## S3 method for class 'POSIXct':
xtfrm(x)
## S3 method for class 'POSIXlt':
xtfrm(x)
## S3 method for class 'Surv':
xtfrm(x)

Arguments

x an object.

Details

xtfrm is a generic function that is an auxiliary function to create a numeric vector sorted in the same order as x. Because xtfrm is an internal primitive function, both S3 and S4 methods can be implemented. Currently, the default method and some methods for other classes are implemented.
Value
returns a numeric vector of the same length as x.
See Also
sort, rank, order
Examples
x <- factor(c("R", "G", "B"))
xtfrm(x)

x <- c(2, 4, 8, 5, 1, 9) xtfrm(x)

x <- c("G", "B", "R") xtfrm(x)

## date-time objects x <- as.Date(c("1997/09/13","2010/05/24","2001/07/18")) xtfrm(x) x <- as.POSIXct(c("1997/09/13","2010/05/24","2001/07/18")) xtfrm(x) x <- as.POSIXlt(c("1997/09/13","2010/05/24","2001/07/18")) xtfrm(x) x <- as.difftime(c("01:02:03","04:05:06","07:08:09")) xtfrm(x)

xtfrm(I(x)) # Example for "AsIs" class

x <- numeric_version(c("2.12.0", "1.4", "2.10.1")) xtfrm(x)

# Example for "Surv" class require(survival) x <- Surv(c(0.1, 0, 3, 1.3), c(3, 24, 7, 3.4), c(TRUE, FALSE, FALSE, TRUE)) xtfrm(x)

Package base version 6.0.0-69
Package Index