scale_to: scale_to

View source: R/scale_to.R

scale_toR Documentation

scale_to

Description

Rescales x such that for the rescaled data 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 rescales x (default: 0)

sd

numeric: standard deviation of 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)

sigbertklinke/exams2moodle documentation built on July 6, 2023, 3:26 p.m.