Aggregate Data

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.

You have several trials of a dependent variable and you would like to get the mean scores at different levels of the independent variables.

Note: "DV1", "DV2", "IV1", "IV2" are names that you are giving to the columns (variables) in the aggregated data set. "DVa", "DVb", "IVa", "IVb" refer to the names in the data set you are collapsing.

_____________________________

XYXY.agg <- aggregate (list (DV1 = ds$DVa, DV2 = ds$DVb),

by = list (Subject = ds$Subject,

IV1 = ds$IVa,

IV2 = ds$IVb),

FUN = mean, na.rm = TRUE)

_____________________________