Learn R Programming

PSAgraphics (version 2.1.3)

cv.trans.psa: Transformation of Factors to Individual Levels

Description

The function cv.trans.psa takes a covariate data frame and replaces each categorical covariate of n >=3 levels with n new binary covariate columns, one for each level. Transforms covariate dataframe for use with the function cv.bal.psa.

Usage

cv.trans.psa(covariates, fcol = NULL)

Value

Returns a dataframe covariates.transformed containing new columns for each level of more than binary factors. The rest of the covariate dataframe stays unchanged.

Arguments

covariates

A dataframe of covariates, presumably some factors.

fcol

An optional vector containing the factor columns in the covariate dataframe. In NULL (default) routine to identfy factors internally.

Author

James E. Helmreich James.Helmreich@Marist.edu

Robert M. Pruzek RMPruzek@yahoo.com

KuangNan Xiong harryxkn@yahoo.com

See Also

cv.bal.psa, loess.psa, cstrata.psa, cv.trans.psa

Examples

Run this code

#Note reordering of columns, binary factor and numeric column are unchanged.
f2 <- factor(sample(c(0, 1), 20, replace = TRUE))
f4 <- factor(sample(c("a", "b", "c", "d"), 20, replace = TRUE))
cv <- rnorm(20)
X <- data.frame(f2, f4, cv)
cv.trans.psa(X)
#
f2 <- factor(sample(c('c', 'C'), 20, replace = TRUE))
f4 <- factor(sample(c("b", "A", "d", "CC"), 20, replace = TRUE))
cv <- rnorm(20)
X <- data.frame(f2, f4, cv)
cv.trans.psa(X)

Run the code above in your browser using DataLab