Learn R Programming

stevemisc (version 1.8.0)

r1sd: Scale a vector by one standard deviation

Description

r1sd allows you to rescale a numeric vector such that the ensuing output has a mean of 0 and a standard deviation of 1.

Usage

r1sd(x, na = TRUE)

Value

The function returns a numeric vector rescaled with a mean of 0 and a standard deviation of 1.

Arguments

x

a numeric vector

na

what to do with NAs in the vector. Defaults to TRUE (i.e. passes over the missing observations)

Details

This is a convenience function since the default rescale() function has some additional weirdness that is not welcome for my use cases. By default, na.rm is set to TRUE.

Examples

Run this code

x <- rnorm(100)
r1sd(x)

Run the code above in your browser using DataLab