transformC {RCPA3}R Documentation

Returns new variables by transforming existing dataset variables (e.g. dummy variables, standardized variables, rank orders)

Description

Given a variable x, the transformC function generates and returns a tranformed version of x. For example, transformC can take a variable x and return standardized x, or the log of x.

Usage

transformC(type, x, data, response, cutpoints, groups, confirm = TRUE, ...)

Arguments

type

The type of transformation to be made to x. Options include:

  • "center"

  • "cut" use cutpoints or groups arguments to control cuts

  • "dummy" use response argument to identify values of x which should be coded 1 (all other non-missing responses will be coded 0)

  • "dummy.set"

  • "ln"

  • "log10"

  • "percent.rank"

  • "rank"

  • "whole"

  • "z"

x

The variable to be transformed, a variable that already exists, should be in dataset$var form unless dataset specified in optional data argument.

data

(Optional) Name of dataset that contains x variable.

response

(Optional) For type="dummy", response is the value or vector of values to be coded 1.

cutpoints

(Optional) For type="cut", a vector of values to serve as lower bounds of ranked categories for transformed x variable.

groups

(Optional) For type="cut", the number of (approximately) same sized groups to create based on x values.

confirm

(Optional) By default, transformC will ask you to confirm you want transformed variable returned (to prevent data loss). Set confirm=FALSE to bypass this check.

...

(Optional) Additional arguments pass to cut2 (for type="cut").

Value

A transformed version of x variable, a vector with the same length as x, unless type="dummy.set" in which case transformC returns a data.frame.

RCPA3 Package Tutorial Videos

Textbook References

Online Resources

Examples

  library(RCPA3)
  
  # don't use confirm=FALSE until you've tested the function call
  transformC("percent.rank", nes$ft.dem, confirm=FALSE)
  transformC("rank", nes$ft.dem, confirm=FALSE)
  transformC("whole", runif(min=0,max=100,n=20), confirm=FALSE)

[Package RCPA3 version 1.2.1 Index]