zscores {schoRsch} | R Documentation |
Compute z-Scores by Condition
Description
Data of an input vector is transformed to z-scores (mean = 0, sd = 1). The function operates on single vectors as well as on specified columns of a data frame.
Usage
zscores(data, factors=NaN, dv=NaN)
Arguments
data |
Either a data frame containing the data of interest or a single vector. |
factors |
If called with |
dv |
If |
Details
zscores
computes z-score of a vector or a specified column within a dataframe. Computation can be done separately for combinations of factors.
Value
zscores()
returns a vector containing the requested z-scores.
Author(s)
Roland Pfister, Markus Janczyk
See Also
Examples
# Create input vector and compute z-scores
measurements <- c(3,12,5,4,2,23,1,6)
zscores(measurements)
# Compute z-scores separately
# for conditions
cond1 <- c(1,1,1,1,2,2,2,2)
cond2 <- c(1,1,2,2,1,1,2,2)
zscores(measurements,list(cond1))
zscores(measurements,list(cond1,cond2))
# Calling zscores for data frames
data <- data.frame(measurements,
cond1,cond2)
zscores(data,dv="measurements",
factors=c("cond1","cond2"))
# Operating on column indices
zscores(data,dv=1,
factors=3)