#### 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)))

_____________________________

â€‹

â€‹