#### Dummy Variables

KEY:

ds = dataset you are currently using.

DV = dependent variable of interest

IV = independent variable of interest

Subject = name of subject number column

XYXY = dummy name for a variable, matrix, or data frame into which you are moving information.

First, please note that when running linear regression in R, dummy variables will be created automatically. That said, I have needed to make them from time to time.

Basic command:

_____________________________

(model.matrix(~XYXY$IV))

_____________________________

To structure it as a data frame:

_____________________________

data.frame(model.matrix(~XYXY$IV))

_____________________________

To integrate the dummy vars into the original data. Note that if you do not want to include the intercept, type the command as "model.matrix(~XYXY$IV)[,c(-1)]))"

_____________________________

XYXY <- data.frame(XYXY, data.frame(model.matrix(~XYXY$IV)))

_____________________________