Last chance! 50% off unlimited learning
Sale ends in
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.
zscores(data, factors=NaN, dv=NaN)
Either a data frame containing the data of interest or a single vector.
If called with factors=NaN
(default), the entire data is processed according to its grand mean and total variance. If data
is a vector, factors
can be a list of variables for splitting the variable into separate compartments. If data
is a data frame, factors
has to be specified as a character vector of column names or column indices.
If data
is a single vector, dv
does not have to be specified. If data
is a data frame, dv
indicates the column of the data frame which contains the variable for z-transformation (e.g., dv="rt"
) or its column index (e.g., dv=15
).
zscores()
returns a vector containing the requested z-scores.
zscores
computes z-score of a vector or a specified column within a dataframe. Computation can be done separately for combinations of factors.
# NOT RUN {
# 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)
# }
Run the code above in your browser using DataLab