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.

- The default method returns the un-class of x if x is numeric; otherwise, it returns the rank of x. (The rank is coerced to a vector).
- "xtfrm.AsIs" removes the "AsIs" class from the vector of class attributes first, and then calls the method of xtfrm.
- "xtfrm.Date", "xtfrm.difftime", "xtfrm.POSIXct", and "xtfrm.POSIXlt" return the coercion of x to double.
- "xtfrm.factor " returns the coercion of x to integer.
- "xtfrm.numeric_version" calls the utility function .encode_numeric_version. (For more information about "xtfrm.numeric_version", see numeric_version.)
- "xtfrm.Surv" returns the order of the columns of a Survival matrix.

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.1.5-18
Package Index