Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Transformations

Function for Data Transformations


Description

Transformations of Response or Input Variables

Usage

ptrafo(data, numeric_trafo = id_trafo, factor_trafo = ff_trafo, 
    ordered_trafo = of_trafo, surv_trafo = logrank_trafo, 
    var_trafo = NULL)
ff_trafo(x)

Arguments

data

an object of class data.frame.

numeric_trafo

a function to by applied to numeric elements of data returning a matrix with nrow(data) rows and an arbitrary number of columns.

ordered_trafo

a function to by applied to ordered elements of data returning a matrix with nrow(data) rows and an arbitrary number of columns (usually some scores).

factor_trafo

a function to by applied to factor elements of data returning a matrix with nrow(data) rows and an arbitrary number of columns (usually a dummy or contrast matrix).

surv_trafo

a function to by applied to elements of class Surv of data returning a matrix with nrow(data) rows and an arbitrary number of columns.

var_trafo

an optional named list of functions to be applied to the corresponding variables in data.

x

a factor

Details

trafo applies its arguments to the elements of data according to the classes of the elements. See Transformations for more documentation and examples.

In the presence of missing values, one needs to make sure that all user-supplied functions deal with that.

Value

A named matrix with nrow(data) rows and arbitrary number of columns.

Examples

### rank a variable
  ptrafo(data.frame(y = 1:20), 
         numeric_trafo = function(x) rank(x, na.last = "keep"))

  ### dummy coding of a factor
  ptrafo(data.frame(y = gl(3, 9)))

party

A Laboratory for Recursive Partytioning

v1.3-10
GPL-2
Authors
Torsten Hothorn [aut, cre] (<https://orcid.org/0000-0001-8301-0471>), Kurt Hornik [aut], Carolin Strobl [aut], Achim Zeileis [aut] (<https://orcid.org/0000-0003-0918-3766>)
Initial release
2022-04-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.