Re: [R] Scale function

From: David Winsemius <>
Date: Wed, 30 Jan 2008 04:48:39 +0000 (UTC)

pellegrini <> wrote in

> There is something that I do not get with scale function.
> Say that I have a vector v <- c(1,2,3,4,5,6),
> scale(v,center=TRUE,scale=TRUE) gives a new vector with 0 as mean
> and 1 as standard deviation.
> but,
> scale(v, center=FALSE,scale=TRUE) gives a new vector with a standard
> deviation different from 1.
> I would also expect a standard deviation of 1 in that case.
> am I wrong ?

Appears that you are. From the help page:

"If scale is TRUE then scaling is done by dividing the (centered) columns of x by their root-mean-square."

"The root-mean-square for a column is obtained by computing the squareroot  of the sum-of-squares of the non-missing values in the column divided by the number of non-missing values minus one."

> sd(scale(warpbreaks$breaks, scale=TRUE)) #default is center=TRUE
[1] 1
> sd(scale(warpbreaks$breaks, center=FALSE, scale=TRUE))
[1] 0.4212988

David Winsemius

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 30 Jan 2008 - 04:54:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 30 Jan 2008 - 05:30:10 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive