View source: R/zscore.by.group.R
| zscore.by.group | R Documentation |
z-scores x within each of one or more cells. For instance, z-score
Likert scale ratings within each participant, or z-score response times
within each participant x condition pairing.
zscore.by.group(x, INDEX)
x |
a numeric vector |
INDEX |
list of one or more grouping variables, typically factors, each of the same length as x |
numeric vector with x z-scored separately within each level
of INDEX
center.by.group to center within groups without
scaling by the standard deviation.
my.data <- data.frame(Subject=c(rep('S1',6), rep('S2',6)),
Session=c(rep('Day1',3), rep('Day2',3),
rep('Day1',3), rep('Day2',3)),
Rating=c(10,30,20,20,40,30,15,35,25,25,45,35))
# z-score within each subject:
my.data$Rating.Subject.z <- zscore.by.group(my.data$Rating, my.data$Subject)
# z-score within each subject x session pairing:
my.data$Rating.SubjectSession.z <- zscore.by.group(my.data$Rating,
list(my.data$Subject, my.data$Session))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.