Data scaling refers to the process of taking each element in a column of data from a dataframe and dividing each point by the standard deviation. Data centering refers to the process of subtracting the mean of the elements in the column from each ppoint.
I will demonstrate how to use the scale() function, which is a simple and straightforward way to center and scale data. In addition, I will show the mathematical steps that each process undergoes.
We’ll use the “palmerpenguins” packages (https://allisonhorst.github.io/palmerpenguins/) to address this question. You’ll need to install the package with install.packages(“palmerpenguins”) if you have not done so before, call library(““palmerpenguins”), and load the data with data(penguins)
#install.packages("palmerpenguins")
library(palmerpenguins)
data(penguins)
For this demonstration, we will use the column bill_length_mm from the penguins data set. To access this column individually, we use the $ operator. We need to do this because we need a numeric vector in order to use scale().
bill_length_mm <- penguins$bill_length_mm
The scale() function is part of base R so you don’t need to install any additional packages. To use the scale function, the 2 arguments we need to understand are the name of the vector, center, and scale. If center and scale are set equal to true, the data will be scaled and centered. If center = TRUE and scale = FALSE, the data will be centered but not scaled. If center = FALSE and scale = TRUE, the data will be scaled but not centered.
scale(bill_length_mm, center = TRUE, scale = TRUE)
## [,1]
## [1,] -0.88320467
## [2,] -0.80993901
## [3,] -0.66340769
## [4,] NA
## [5,] -1.32279862
## [6,] -0.84657184
## [7,] -0.91983750
## [8,] -0.86488825
## [9,] -1.79902541
## [10,] -0.35202864
## [11,] -1.12131806
## [12,] -1.12131806
## [13,] -0.51687637
## [14,] -0.97478674
## [15,] -1.70744334
## [16,] -1.34111504
## [17,] -0.95647033
## [18,] -0.26044656
## [19,] -1.74407616
## [20,] 0.38062795
## [21,] -1.12131806
## [22,] -1.13963448
## [23,] -1.46932994
## [24,] -1.04805240
## [25,] -0.93815391
## [26,] -1.57922843
## [27,] -0.60845845
## [28,] -0.62677486
## [29,] -1.10300165
## [30,] -0.62677486
## [31,] -0.80993901
## [32,] -1.23121655
## [33,] -0.80993901
## [34,] -0.55350920
## [35,] -1.37774787
## [36,] -0.86488825
## [37,] -0.93815391
## [38,] -0.31539581
## [39,] -1.15795089
## [40,] -0.75498976
## [41,] -1.35943145
## [42,] -0.57182562
## [43,] -1.45101353
## [44,] 0.03261607
## [45,] -1.26784938
## [46,] -0.79162259
## [47,] -0.51687637
## [48,] -1.17626731
## [49,] -1.45101353
## [50,] -0.29707939
## [51,] -0.79162259
## [52,] -0.70004052
## [53,] -1.63417768
## [54,] -0.35202864
## [55,] -1.72575975
## [56,] -0.46192713
## [57,] -0.90152108
## [58,] -0.60845845
## [59,] -1.35943145
## [60,] -1.15795089
## [61,] -1.50596277
## [62,] -0.48024354
## [63,] -1.15795089
## [64,] -0.51687637
## [65,] -1.37774787
## [66,] -0.42529430
## [67,] -1.54259560
## [68,] -0.51687637
## [69,] -1.46932994
## [70,] -0.38866147
## [71,] -1.90892390
## [72,] -0.77330618
## [73,] -0.79162259
## [74,] 0.34399512
## [75,] -1.54259560
## [76,] -0.20549732
## [77,] -0.55350920
## [78,] -1.23121655
## [79,] -1.41438070
## [80,] -0.33371222
## [81,] -1.70744334
## [82,] -0.18718091
## [83,] -1.32279862
## [84,] -1.61586126
## [85,] -1.21290014
## [86,] -0.48024354
## [87,] -1.39606428
## [88,] -1.28616579
## [89,] -1.02973599
## [90,] -0.91983750
## [91,] -1.50596277
## [92,] -0.51687637
## [93,] -1.81734182
## [94,] -0.79162259
## [95,] -1.41438070
## [96,] -0.57182562
## [97,] -1.06636882
## [98,] -0.66340769
## [99,] -1.98218956
## [100,] -0.13223166
## [101,] -1.63417768
## [102,] -0.53519279
## [103,] -1.13963448
## [104,] -1.12131806
## [105,] -1.10300165
## [106,] -0.77330618
## [107,] -0.97478674
## [108,] -1.04805240
## [109,] -1.06636882
## [110,] -0.13223166
## [111,] -1.06636882
## [112,] 0.30736229
## [113,] -0.77330618
## [114,] -0.31539581
## [115,] -0.79162259
## [116,] -0.22381374
## [117,] -0.97478674
## [118,] -1.21290014
## [119,] -1.50596277
## [120,] -0.51687637
## [121,] -1.41438070
## [122,] -1.13963448
## [123,] -0.68172411
## [124,] -0.46192713
## [125,] -1.59754485
## [126,] -0.60845845
## [127,] -0.93815391
## [128,] -0.44361071
## [129,] -0.90152108
## [130,] 0.03261607
## [131,] -0.99310316
## [132,] -0.15054808
## [133,] -1.30448221
## [134,] -1.17626731
## [135,] -1.06636882
## [136,] -0.51687637
## [137,] -1.52427919
## [138,] -0.68172411
## [139,] -1.26784938
## [140,] -0.77330618
## [141,] -0.68172411
## [142,] -0.60845845
## [143,] -2.16535371
## [144,] -0.59014203
## [145,] -1.21290014
## [146,] -0.90152108
## [147,] -0.86488825
## [148,] -1.34111504
## [149,] -1.45101353
## [150,] -1.12131806
## [151,] -1.45101353
## [152,] -0.44361071
## [153,] 0.39894437
## [154,] 1.11328455
## [155,] 0.87517115
## [156,] 1.11328455
## [157,] 0.67369059
## [158,] 0.47221003
## [159,] 0.27072946
## [160,] 0.50884286
## [161,] -0.11391525
## [162,] 0.52715927
## [163,] -0.55350920
## [164,] 0.93012040
## [165,] 0.28904588
## [166,] 0.82022191
## [167,] 0.34399512
## [168,] 0.98506964
## [169,] -0.35202864
## [170,] 0.96675323
## [171,] 0.41726078
## [172,] 0.87517115
## [173,] 1.14991738
## [174,] 0.21578022
## [175,] 0.47221003
## [176,] 0.43557720
## [177,] -0.18718091
## [178,] 0.39894437
## [179,] 0.10588173
## [180,] 0.71032342
## [181,] 0.78358908
## [182,] 1.11328455
## [183,] 0.61874135
## [184,] -0.20549732
## [185,] 0.21578022
## [186,] 2.87166037
## [187,] 0.94843681
## [188,] 0.82022191
## [189,] -0.24213015
## [190,] 0.08756532
## [191,] 0.01429966
## [192,] 0.87517115
## [193,] -0.22381374
## [194,] 1.04001889
## [195,] 0.25241305
## [196,] 1.04001889
## [197,] 1.20486662
## [198,] -0.05896600
## [199,] 0.28904588
## [200,] 1.20486662
## [201,] 0.17914739
## [202,] 0.23409663
## [203,] 0.49052644
## [204,] 0.83853832
## [205,] 0.21578022
## [206,] 1.13160096
## [207,] 0.47221003
## [208,] 0.19746381
## [209,] -0.02233317
## [210,] 0.28904588
## [211,] -0.13223166
## [212,] 1.18655021
## [213,] 0.25241305
## [214,] 0.41726078
## [215,] 0.32567871
## [216,] 1.90089038
## [217,] 0.34399512
## [218,] 1.07665172
## [219,] 0.41726078
## [220,] 1.02170247
## [221,] -0.07728242
## [222,] 1.24149945
## [223,] 0.69200701
## [224,] 0.45389361
## [225,] 0.78358908
## [226,] 0.47221003
## [227,] 0.45389361
## [228,] 0.85685474
## [229,] 0.65537418
## [230,] 1.31476511
## [231,] 0.23409663
## [232,] 0.23409663
## [233,] 0.94843681
## [234,] 1.57119492
## [235,] 0.63705776
## [236,] 1.11328455
## [237,] 0.17914739
## [238,] 1.25981586
## [239,] -0.09559883
## [240,] 1.35139794
## [241,] 0.65537418
## [242,] 1.49792926
## [243,] 0.65537418
## [244,] 1.51624567
## [245,] 0.28904588
## [246,] 1.02170247
## [247,] 0.10588173
## [248,] 1.25981586
## [249,] 1.00338606
## [250,] 0.54547569
## [251,] 0.82022191
## [252,] 1.31476511
## [253,] 0.83853832
## [254,] 2.19395302
## [255,] 0.60042493
## [256,] 0.94843681
## [257,] 0.61874135
## [258,] 0.52715927
## [259,] -0.40697788
## [260,] 1.73604265
## [261,] -0.11391525
## [262,] 0.76527266
## [263,] 1.20486662
## [264,] 1.07665172
## [265,] -0.07728242
## [266,] 1.38803077
## [267,] 0.41726078
## [268,] 2.04742170
## [269,] 0.10588173
## [270,] 0.89348757
## [271,] 0.60042493
## [272,] NA
## [273,] 0.52715927
## [274,] 1.18655021
## [275,] 0.23409663
## [276,] 1.09496813
## [277,] 0.47221003
## [278,] 1.11328455
## [279,] 1.35139794
## [280,] 0.27072946
## [281,] 1.60782775
## [282,] 0.23409663
## [283,] 0.39894437
## [284,] 1.35139794
## [285,] 0.38062795
## [286,] 1.35139794
## [287,] 0.49052644
## [288,] 1.42466360
## [289,] 0.56379210
## [290,] 1.47961284
## [291,] 0.36231154
## [292,] 1.20486662
## [293,] 1.16823379
## [294,] 2.57859773
## [295,] 0.45389361
## [296,] 0.96675323
## [297,] -0.27876298
## [298,] 0.83853832
## [299,] -0.13223166
## [300,] 1.22318303
## [301,] 0.50884286
## [302,] 1.47961284
## [303,] 1.20486662
## [304,] 1.02170247
## [305,] 0.45389361
## [306,] 1.62614416
## [307,] -0.55350920
## [308,] 1.88257397
## [309,] -0.26044656
## [310,] 1.29644869
## [311,] 1.05833530
## [312,] 0.65537418
## [313,] 0.67369059
## [314,] 1.47961284
## [315,] 0.54547569
## [316,] 1.75435906
## [317,] 0.93012040
## [318,] 0.41726078
## [319,] 1.27813228
## [320,] 0.28904588
## [321,] 1.27813228
## [322,] 1.25981586
## [323,] 1.13160096
## [324,] 0.93012040
## [325,] 1.38803077
## [326,] 1.07665172
## [327,] 0.76527266
## [328,] 1.36971435
## [329,] 0.32567871
## [330,] 1.24149945
## [331,] -0.26044656
## [332,] 1.51624567
## [333,] 0.23409663
## [334,] 0.98506964
## [335,] 1.14991738
## [336,] 0.30736229
## [337,] 1.46129643
## [338,] 0.52715927
## [339,] 0.32567871
## [340,] 2.17563660
## [341,] -0.07728242
## [342,] 1.04001889
## [343,] 1.25981586
## [344,] 1.14991738
## attr(,"scaled:center")
## [1] 43.92193
## attr(,"scaled:scale")
## [1] 5.459584
Mathematically, data centering involves subtracting the mean from each data point. The mean() function in base R calculates the mean of the given numeric vector. The na.rm argument omits all NA values when calculating the mean, if set to true.
bill_length_mean <- mean(bill_length_mm, na.rm = TRUE)
centered <- bill_length_mm - bill_length_mean
centered
## [1] -4.82192982 -4.42192982 -3.62192982 NA -7.22192982
## [6] -4.62192982 -5.02192982 -4.72192982 -9.82192982 -1.92192982
## [11] -6.12192982 -6.12192982 -2.82192982 -5.32192982 -9.32192982
## [16] -7.32192982 -5.22192982 -1.42192982 -9.52192982 2.07807018
## [21] -6.12192982 -6.22192982 -8.02192982 -5.72192982 -5.12192982
## [26] -8.62192982 -3.32192982 -3.42192982 -6.02192982 -3.42192982
## [31] -4.42192982 -6.72192982 -4.42192982 -3.02192982 -7.52192982
## [36] -4.72192982 -5.12192982 -1.72192982 -6.32192982 -4.12192982
## [41] -7.42192982 -3.12192982 -7.92192982 0.17807018 -6.92192982
## [46] -4.32192982 -2.82192982 -6.42192982 -7.92192982 -1.62192982
## [51] -4.32192982 -3.82192982 -8.92192982 -1.92192982 -9.42192982
## [56] -2.52192982 -4.92192982 -3.32192982 -7.42192982 -6.32192982
## [61] -8.22192982 -2.62192982 -6.32192982 -2.82192982 -7.52192982
## [66] -2.32192982 -8.42192982 -2.82192982 -8.02192982 -2.12192982
## [71] -10.42192982 -4.22192982 -4.32192982 1.87807018 -8.42192982
## [76] -1.12192982 -3.02192982 -6.72192982 -7.72192982 -1.82192982
## [81] -9.32192982 -1.02192982 -7.22192982 -8.82192982 -6.62192982
## [86] -2.62192982 -7.62192982 -7.02192982 -5.62192982 -5.02192982
## [91] -8.22192982 -2.82192982 -9.92192982 -4.32192982 -7.72192982
## [96] -3.12192982 -5.82192982 -3.62192982 -10.82192982 -0.72192982
## [101] -8.92192982 -2.92192982 -6.22192982 -6.12192982 -6.02192982
## [106] -4.22192982 -5.32192982 -5.72192982 -5.82192982 -0.72192982
## [111] -5.82192982 1.67807018 -4.22192982 -1.72192982 -4.32192982
## [116] -1.22192982 -5.32192982 -6.62192982 -8.22192982 -2.82192982
## [121] -7.72192982 -6.22192982 -3.72192982 -2.52192982 -8.72192982
## [126] -3.32192982 -5.12192982 -2.42192982 -4.92192982 0.17807018
## [131] -5.42192982 -0.82192982 -7.12192982 -6.42192982 -5.82192982
## [136] -2.82192982 -8.32192982 -3.72192982 -6.92192982 -4.22192982
## [141] -3.72192982 -3.32192982 -11.82192982 -3.22192982 -6.62192982
## [146] -4.92192982 -4.72192982 -7.32192982 -7.92192982 -6.12192982
## [151] -7.92192982 -2.42192982 2.17807018 6.07807018 4.77807018
## [156] 6.07807018 3.67807018 2.57807018 1.47807018 2.77807018
## [161] -0.62192982 2.87807018 -3.02192982 5.07807018 1.57807018
## [166] 4.47807018 1.87807018 5.37807018 -1.92192982 5.27807018
## [171] 2.27807018 4.77807018 6.27807018 1.17807018 2.57807018
## [176] 2.37807018 -1.02192982 2.17807018 0.57807018 3.87807018
## [181] 4.27807018 6.07807018 3.37807018 -1.12192982 1.17807018
## [186] 15.67807018 5.17807018 4.47807018 -1.32192982 0.47807018
## [191] 0.07807018 4.77807018 -1.22192982 5.67807018 1.37807018
## [196] 5.67807018 6.57807018 -0.32192982 1.57807018 6.57807018
## [201] 0.97807018 1.27807018 2.67807018 4.57807018 1.17807018
## [206] 6.17807018 2.57807018 1.07807018 -0.12192982 1.57807018
## [211] -0.72192982 6.47807018 1.37807018 2.27807018 1.77807018
## [216] 10.37807018 1.87807018 5.87807018 2.27807018 5.57807018
## [221] -0.42192982 6.77807018 3.77807018 2.47807018 4.27807018
## [226] 2.57807018 2.47807018 4.67807018 3.57807018 7.17807018
## [231] 1.27807018 1.27807018 5.17807018 8.57807018 3.47807018
## [236] 6.07807018 0.97807018 6.87807018 -0.52192982 7.37807018
## [241] 3.57807018 8.17807018 3.57807018 8.27807018 1.57807018
## [246] 5.57807018 0.57807018 6.87807018 5.47807018 2.97807018
## [251] 4.47807018 7.17807018 4.57807018 11.97807018 3.27807018
## [256] 5.17807018 3.37807018 2.87807018 -2.22192982 9.47807018
## [261] -0.62192982 4.17807018 6.57807018 5.87807018 -0.42192982
## [266] 7.57807018 2.27807018 11.17807018 0.57807018 4.87807018
## [271] 3.27807018 NA 2.87807018 6.47807018 1.27807018
## [276] 5.97807018 2.57807018 6.07807018 7.37807018 1.47807018
## [281] 8.77807018 1.27807018 2.17807018 7.37807018 2.07807018
## [286] 7.37807018 2.67807018 7.77807018 3.07807018 8.07807018
## [291] 1.97807018 6.57807018 6.37807018 14.07807018 2.47807018
## [296] 5.27807018 -1.52192982 4.57807018 -0.72192982 6.67807018
## [301] 2.77807018 8.07807018 6.57807018 5.57807018 2.47807018
## [306] 8.87807018 -3.02192982 10.27807018 -1.42192982 7.07807018
## [311] 5.77807018 3.57807018 3.67807018 8.07807018 2.97807018
## [316] 9.57807018 5.07807018 2.27807018 6.97807018 1.57807018
## [321] 6.97807018 6.87807018 6.17807018 5.07807018 7.57807018
## [326] 5.87807018 4.17807018 7.47807018 1.77807018 6.77807018
## [331] -1.42192982 8.27807018 1.27807018 5.37807018 6.27807018
## [336] 1.67807018 7.97807018 2.87807018 1.77807018 11.87807018
## [341] -0.42192982 5.67807018 6.87807018 6.27807018
Mathematically, data scaling involves dividing each point by the standard deviation. To calculate standard deviation, we use the sd() function. The na.rm argument omits all NA values when calculating the standard deviation, if set to true.
bill_length_sd <- sd(bill_length_mm, na.rm = TRUE)
scaled <- bill_length_mm/bill_length_sd
scaled
## [1] 7.161718 7.234984 7.381515 NA 6.722124 7.198351 7.125085
## [8] 7.180035 6.245897 7.692894 6.923605 6.923605 7.528046 7.070136
## [15] 6.337480 6.703808 7.088453 7.784476 6.300847 8.425551 6.923605
## [22] 6.905288 6.575593 6.996870 7.106769 6.465694 7.436464 7.418148
## [29] 6.941921 7.418148 7.234984 6.813706 7.234984 7.491414 6.667175
## [36] 7.180035 7.106769 7.729527 6.886972 7.289933 6.685491 7.473097
## [43] 6.593909 8.077539 6.777073 7.253300 7.528046 6.868656 6.593909
## [50] 7.747843 7.253300 7.344882 6.410745 7.692894 6.319163 7.582996
## [57] 7.143402 7.436464 6.685491 6.886972 6.538960 7.564679 6.886972
## [64] 7.528046 6.667175 7.619629 6.502327 7.528046 6.575593 7.656261
## [71] 6.135999 7.271617 7.253300 8.388918 6.502327 7.839426 7.491414
## [78] 6.813706 6.630542 7.711211 6.337480 7.857742 6.722124 6.429062
## [85] 6.832023 7.564679 6.648859 6.758757 7.015187 7.125085 6.538960
## [92] 7.528046 6.227581 7.253300 6.630542 7.473097 6.978554 7.381515
## [99] 6.062733 7.912691 6.410745 7.509730 6.905288 6.923605 6.941921
## [106] 7.271617 7.070136 6.996870 6.978554 7.912691 6.978554 8.352285
## [113] 7.271617 7.729527 7.253300 7.821109 7.070136 6.832023 6.538960
## [120] 7.528046 6.630542 6.905288 7.363199 7.582996 6.447378 7.436464
## [127] 7.106769 7.601312 7.143402 8.077539 7.051820 7.894375 6.740441
## [134] 6.868656 6.978554 7.528046 6.520644 7.363199 6.777073 7.271617
## [141] 7.363199 7.436464 5.879569 7.454781 6.832023 7.143402 7.180035
## [148] 6.703808 6.593909 6.923605 6.593909 7.601312 8.443867 9.158207
## [155] 8.920094 9.158207 8.718613 8.517133 8.315652 8.553766 7.931008
## [162] 8.572082 7.491414 8.975043 8.333969 8.865145 8.388918 9.029993
## [169] 7.692894 9.011676 8.462184 8.920094 9.194840 8.260703 8.517133
## [176] 8.480500 7.857742 8.443867 8.150805 8.755246 8.828512 9.158207
## [183] 8.663664 7.839426 8.260703 10.916583 8.993360 8.865145 7.802793
## [190] 8.132488 8.059223 8.920094 7.821109 9.084942 8.297336 9.084942
## [197] 9.249789 7.985957 8.333969 9.249789 8.224070 8.279019 8.535449
## [204] 8.883461 8.260703 9.176524 8.517133 8.242387 8.022590 8.333969
## [211] 7.912691 9.231473 8.297336 8.462184 8.370602 9.945813 8.388918
## [218] 9.121575 8.462184 9.066625 7.967640 9.286422 8.736930 8.498816
## [225] 8.828512 8.517133 8.498816 8.901778 8.700297 9.359688 8.279019
## [232] 8.279019 8.993360 9.616118 8.681981 9.158207 8.224070 9.304739
## [239] 7.949324 9.396321 8.700297 9.542852 8.700297 9.561169 8.333969
## [246] 9.066625 8.150805 9.304739 9.048309 8.590399 8.865145 9.359688
## [253] 8.883461 10.238876 8.645348 8.993360 8.663664 8.572082 7.637945
## [260] 9.780966 7.931008 8.810196 9.249789 9.121575 7.967640 9.432954
## [267] 8.462184 10.092345 8.150805 8.938410 8.645348 NA 8.572082
## [274] 9.231473 8.279019 9.139891 8.517133 9.158207 9.396321 8.315652
## [281] 9.652751 8.279019 8.443867 9.396321 8.425551 9.396321 8.535449
## [288] 9.469586 8.608715 9.524536 8.407234 9.249789 9.213157 10.623521
## [295] 8.498816 9.011676 7.766160 8.883461 7.912691 9.268106 8.553766
## [302] 9.524536 9.249789 9.066625 8.498816 9.671067 7.491414 9.927497
## [309] 7.784476 9.341372 9.103258 8.700297 8.718613 9.524536 8.590399
## [316] 9.799282 8.975043 8.462184 9.323055 8.333969 9.323055 9.304739
## [323] 9.176524 8.975043 9.432954 9.121575 8.810196 9.414637 8.370602
## [330] 9.286422 7.784476 9.561169 8.279019 9.029993 9.194840 8.352285
## [337] 9.506219 8.572082 8.370602 10.220559 7.967640 9.084942 9.304739
## [344] 9.194840
In the following code chunk, I am scaling and centering the data simultaneously.
scaled_and_centered <- (bill_length_mm - bill_length_mean)/bill_length_sd
scaled_and_centered
## [1] -0.88320467 -0.80993901 -0.66340769 NA -1.32279862 -0.84657184
## [7] -0.91983750 -0.86488825 -1.79902541 -0.35202864 -1.12131806 -1.12131806
## [13] -0.51687637 -0.97478674 -1.70744334 -1.34111504 -0.95647033 -0.26044656
## [19] -1.74407616 0.38062795 -1.12131806 -1.13963448 -1.46932994 -1.04805240
## [25] -0.93815391 -1.57922843 -0.60845845 -0.62677486 -1.10300165 -0.62677486
## [31] -0.80993901 -1.23121655 -0.80993901 -0.55350920 -1.37774787 -0.86488825
## [37] -0.93815391 -0.31539581 -1.15795089 -0.75498976 -1.35943145 -0.57182562
## [43] -1.45101353 0.03261607 -1.26784938 -0.79162259 -0.51687637 -1.17626731
## [49] -1.45101353 -0.29707939 -0.79162259 -0.70004052 -1.63417768 -0.35202864
## [55] -1.72575975 -0.46192713 -0.90152108 -0.60845845 -1.35943145 -1.15795089
## [61] -1.50596277 -0.48024354 -1.15795089 -0.51687637 -1.37774787 -0.42529430
## [67] -1.54259560 -0.51687637 -1.46932994 -0.38866147 -1.90892390 -0.77330618
## [73] -0.79162259 0.34399512 -1.54259560 -0.20549732 -0.55350920 -1.23121655
## [79] -1.41438070 -0.33371222 -1.70744334 -0.18718091 -1.32279862 -1.61586126
## [85] -1.21290014 -0.48024354 -1.39606428 -1.28616579 -1.02973599 -0.91983750
## [91] -1.50596277 -0.51687637 -1.81734182 -0.79162259 -1.41438070 -0.57182562
## [97] -1.06636882 -0.66340769 -1.98218956 -0.13223166 -1.63417768 -0.53519279
## [103] -1.13963448 -1.12131806 -1.10300165 -0.77330618 -0.97478674 -1.04805240
## [109] -1.06636882 -0.13223166 -1.06636882 0.30736229 -0.77330618 -0.31539581
## [115] -0.79162259 -0.22381374 -0.97478674 -1.21290014 -1.50596277 -0.51687637
## [121] -1.41438070 -1.13963448 -0.68172411 -0.46192713 -1.59754485 -0.60845845
## [127] -0.93815391 -0.44361071 -0.90152108 0.03261607 -0.99310316 -0.15054808
## [133] -1.30448221 -1.17626731 -1.06636882 -0.51687637 -1.52427919 -0.68172411
## [139] -1.26784938 -0.77330618 -0.68172411 -0.60845845 -2.16535371 -0.59014203
## [145] -1.21290014 -0.90152108 -0.86488825 -1.34111504 -1.45101353 -1.12131806
## [151] -1.45101353 -0.44361071 0.39894437 1.11328455 0.87517115 1.11328455
## [157] 0.67369059 0.47221003 0.27072946 0.50884286 -0.11391525 0.52715927
## [163] -0.55350920 0.93012040 0.28904588 0.82022191 0.34399512 0.98506964
## [169] -0.35202864 0.96675323 0.41726078 0.87517115 1.14991738 0.21578022
## [175] 0.47221003 0.43557720 -0.18718091 0.39894437 0.10588173 0.71032342
## [181] 0.78358908 1.11328455 0.61874135 -0.20549732 0.21578022 2.87166037
## [187] 0.94843681 0.82022191 -0.24213015 0.08756532 0.01429966 0.87517115
## [193] -0.22381374 1.04001889 0.25241305 1.04001889 1.20486662 -0.05896600
## [199] 0.28904588 1.20486662 0.17914739 0.23409663 0.49052644 0.83853832
## [205] 0.21578022 1.13160096 0.47221003 0.19746381 -0.02233317 0.28904588
## [211] -0.13223166 1.18655021 0.25241305 0.41726078 0.32567871 1.90089038
## [217] 0.34399512 1.07665172 0.41726078 1.02170247 -0.07728242 1.24149945
## [223] 0.69200701 0.45389361 0.78358908 0.47221003 0.45389361 0.85685474
## [229] 0.65537418 1.31476511 0.23409663 0.23409663 0.94843681 1.57119492
## [235] 0.63705776 1.11328455 0.17914739 1.25981586 -0.09559883 1.35139794
## [241] 0.65537418 1.49792926 0.65537418 1.51624567 0.28904588 1.02170247
## [247] 0.10588173 1.25981586 1.00338606 0.54547569 0.82022191 1.31476511
## [253] 0.83853832 2.19395302 0.60042493 0.94843681 0.61874135 0.52715927
## [259] -0.40697788 1.73604265 -0.11391525 0.76527266 1.20486662 1.07665172
## [265] -0.07728242 1.38803077 0.41726078 2.04742170 0.10588173 0.89348757
## [271] 0.60042493 NA 0.52715927 1.18655021 0.23409663 1.09496813
## [277] 0.47221003 1.11328455 1.35139794 0.27072946 1.60782775 0.23409663
## [283] 0.39894437 1.35139794 0.38062795 1.35139794 0.49052644 1.42466360
## [289] 0.56379210 1.47961284 0.36231154 1.20486662 1.16823379 2.57859773
## [295] 0.45389361 0.96675323 -0.27876298 0.83853832 -0.13223166 1.22318303
## [301] 0.50884286 1.47961284 1.20486662 1.02170247 0.45389361 1.62614416
## [307] -0.55350920 1.88257397 -0.26044656 1.29644869 1.05833530 0.65537418
## [313] 0.67369059 1.47961284 0.54547569 1.75435906 0.93012040 0.41726078
## [319] 1.27813228 0.28904588 1.27813228 1.25981586 1.13160096 0.93012040
## [325] 1.38803077 1.07665172 0.76527266 1.36971435 0.32567871 1.24149945
## [331] -0.26044656 1.51624567 0.23409663 0.98506964 1.14991738 0.30736229
## [337] 1.46129643 0.52715927 0.32567871 2.17563660 -0.07728242 1.04001889
## [343] 1.25981586 1.14991738
For more information on this topic, see https://scientistcafe.com/ids/centering-and-scaling.html