scale2: Scale a variable to a new mean and standard deviation

View source: R/scale2.R

scale2R Documentation

Scale a variable to a new mean and standard deviation

Description

Scale a variable to a new mean and standard deviation

Usage

scale2(x, newmean = 0, newsd = 1, yj = F)

Arguments

x

Data to scale

newmean

Desired mean

newsd

Desired standard deviation

yj

[logical] Whether Yeo-Johnson transformation should be applied to minimize univariate skew

Examples


y <- c(rnorm(200,3,3),rnorm(100,10,3) )
hist(y, breaks = 40)
hist(scale2(y,4,2), breaks = 40)
hist(scale2(y,-1,.5), breaks = 40)
hist(scale2(y,10,1,yj=T),breaks = 40)
hist(scale2(exp(y),10,1,yj=F),breaks = 40)
hist(scale2(exp(y),10,1,yj=T),breaks = 40)


akcochrane/ACmisc documentation built on Nov. 24, 2024, 11:22 a.m.