unit_scale: Scale a numeric vector

Description Usage Arguments Details Value Examples

Description

Vectors are scaled to have a mean of 0.5 and standard deviation of 0.5.

Usage

1
unit_scale(x, y = NULL, na.rm = TRUE)

Arguments

x

numeric vector

y

alternative numeric vector that contains the attributes to use to rescale x

na.rm

remove NAs from the vector before finding stats

Details

The function works similar to scale, in that attributes of the original mean and standard deviation are saved in the object called center and scale. The adjustment is also provided in the adj attribute.

Value

scaled vector

Examples

1
2
3
4
5
6
7
x <- rnorm(1000, 50, 5)
hist(x, br=50)

y <- unit_scale(x)
hist(y, br=50)
mean(y) # <- 0.5
sd(y) # <- 0.5

iamamutt/SRE documentation built on May 8, 2019, 3:12 a.m.