Scaling a numeric matrix in R with values 0 to 1

前端 未结 5 670
日久生厌
日久生厌 2020-12-09 10:43

Here is an excerpt of numeric matrix that I have

 [1,]   30 -33.129487   3894754.1 -39.701738 -38.356477 -34.220534
 [2,]   29 -44.289487  -8217525.9 -44.801         


        
5条回答
  •  我在风中等你
    2020-12-09 10:47

    And if you were still to use scale:

    maxs <- apply(a, 2, max)
    mins <- apply(a, 2, min)
    scale(a, center = mins, scale = maxs - mins)
    

提交回复
热议问题