Scaling a numeric matrix in R with values 0 to 1

前端 未结 5 669
日久生厌
日久生厌 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 11:06

    scales package has a function called rescale:

    set.seed(2020)
    
    x <- runif(5, 100, 150)
    scales::rescale(x)
    #1.0000000 0.5053362 0.9443995 0.6671695 0.0000000
    

提交回复
热议问题