Understanding `scale` in R

后端 未结 4 858
日久生厌
日久生厌 2020-12-12 15:50

I\'m trying to understand the definition of scale that R provides. I have data (mydata) that I want to make a heat map with, and there is a VERY st

4条回答
  •  一个人的身影
    2020-12-12 16:16

    This is a late addition but I was looking for information on the scale function myself and though it might help somebody else as well.

    To modify the response from Ricardo Saporta a little bit.
    Scaling is not done using standard deviation, at least not in version 3.6.1 of R, I base this on "Becker, R. (2018). The new S language. CRC Press." and my own experimentation.

    X.man.scaled <- X/sqrt(sum(X^2)/(length(X)-1))
    X.aut.scaled <- scale(X, center = F)
    

    The result of these rows are exactly the same, I show it without centering because of simplicity.

    I would respond in a comment but did not have enough reputation.

提交回复
热议问题