code_poly: Build polynomial predictor variables

Description Usage Arguments Value Examples

View source: R/code_poly.R

Description

Takes a data frame, name of predictor variable, and polynomial order. Creates polynomial-transformed predictor variables, adds them to the data frame and returns the result. Original data frame is unchanged, remember to assign the result.

Usage

1
2
code_poly(df = NULL, predictor = NULL, poly.order = NULL,
  orthogonal = TRUE, draw.poly = TRUE)

Arguments

df

data frame, should not contain any variables called "predictor"

predictor

string name of predictor variable

poly.order

integer order of polynomial to be created

orthogonal

logical value indicating whether polynomial should be orthogonal (default) or natural (aka raw)

draw.poly

logical value indicating whether to create a graph showing tranformed polynomial predictor values, defaults to TRUE

Value

Returns a data frame containing the original data and at least two new columns: "predictor".Index, and a column for each order of the polynomial-transformed predictor

Examples

1
2
WordLearnEx.gca <- code_poly(df=WordLearnEx, predictor="Block", poly.order=2)
Az.gca <- code_poly(df=Az, predictor="Time", poly.order=2, orthogonal=FALSE)

jgeller112/gazer documentation built on Jan. 13, 2020, 1:04 p.m.