Descriptive Statistics
KEY:
ds = dataset you are currently using.
â€‹
DV = dependent variable of interest
â€‹
IV = independent variable of interest
â€‹
XYXY = dummy name for a variable, matrix, or data frame into which you are moving information.
Extract descriptives, by levels of independent variable as.factor!!!!!
Step 1: Tell R that your independent variables have discrete levels
R assumes that variables are continuous. In order to tell it otherwise, use the factor function.
_____________________________
ds$IV < as.factor(ds$IV)
ds$Subject < as.factor(ds$Subject)
_____________________________
â€‹
At this step, you can also add labels to the data if you desire
_____________________________
ds$IV < factor(ds$IV,
levels = c(0,1),
labels = c("Label for 0", "Label for 1"))
_____________________________
Step 2: Extract descriptives
The psych package includes a describeBy function that allows descriptives to be produced with respect to any independent variables.

To get main effects, simply only include one IV

mat=TRUE outputs data in a matrix format, which makes it easier to work with

again, type refers to the manner in which skew and kurtosis are calculated

Per Joanes and Gill (1998), type 2 has been adopted by SPSS, SAS, and Excel


digits=2 refers to the number of significant digits reported. Adjust as needed
_____________________________
library(psych)
XYXY <describeBy(ds$DV,
group = ds$IV1 : ds$IV2,
mat=TRUE,
type = 2,
digits = 2)
_____________________________
â€‹