scale_to: Rescaling

View source: R/scale_to.R

scale_toR Documentation

Rescaling

Description

Rescales x such that for the rescaled data it holds: mean(scale_to(x, mean=target))==target and sd(scale_to(x, sd=target)==abs(target). A negative value of sd will change the sign of the x values.

Usage

scale_to(x, mean = 0, sd = 1)

Arguments

x

numeric: vector of values

mean

numeric: mean of the rescaled x (default: 0)

sd

numeric: standard deviation of the transformed x (default: 1)

Value

Rescaled data.

Examples

x <- runif(50)
y <- scale_to(x, mean=0.1, sd=0.2)
mean(y)
sd(y)
y <- scale_to(x, mean=0.1, sd=-0.2)
mean(y)
sd(y)

exams.forge documentation built on Sept. 11, 2024, 5:32 p.m.