Learn R Programming

QuantPsyc (version 1.6)

Make.Z: Standardize Data

Description

Converts data to standard normal (mean = 0; SD = 1) - i.e., z-scores.

Usage

Make.Z(x)

Arguments

x

Any data object (especially useful for multiple columns of a data.frame).

Value

A numeric or matrix containing standardized data (i.e., z scores)

Warning

The result is a matrix. One may wish to convert to data.frame or use as.data.frame(Make.Z(x))

Details

Takes the data (by columns if necessary) and subtracts out the mean and then divides by the standard deviation. The result is a standard normal z score.

Examples

Run this code
# NOT RUN {
zUSJR <- Make.Z(USJudgeRatings)	# creates new object containg z scores
dim(zUSJR)			# shows that there are 43 observed z scores for 12 variables
zUSJR[,1]			# to look at only the first column of z scores

# }

Run the code above in your browser using DataLab