Rescales (minMax, z-score, rank) values per column in a dataframe.

rescaleColumns(x, method = "minMax", max = 100, decim = 2)

Arguments

x

A dataframe. Column 1 - statistical units (countries, regions, companies etc.). Column 2 - time (year, or month, or day etc. - numeric). Rest of columns - values for individual variables.

method

Specifies the rescaling method: "minmax", "z-score", or "rank". The default is "minmax". Equal ranks are averaged.

max

Numeric. In case of method="minmax", specifies the value to be taken by the maximum value in a column. The default is 100.

decim

Numeric. Specifies the number of decimals to display. Default is 2.

Value

A matrix. The first two columns and the colnames are the same as those of x.

References

For theoretical information on the three rescaling methods, check: Nardo et al.(2008). Handbook on Constructing Composite Indicators and User Guide. Publisher: OECD; Editor: European Commission, Joint Research Centre and OECD.

Examples

dataTest_moreYears[c(1:5,27:32),1:5]
#>           country time fixedTerm fixedTermComp selfEmployment
#> 1         Belgium 2001  243.0769     300.42918       485.8757
#> 2        Bulgaria 2001  160.0000     145.92275             NA
#> 3  Czech Republic 2001        NA            NA       146.8927
#> 4         Denmark 2001  261.5385     163.09013       242.9379
#> 5         Germany 2001  353.8462      55.79399       310.7345
#> 27         Sweden 2001  449.2308     167.38197       214.6893
#> 28 United Kingdom 2001  175.3846      72.96137       570.6215
#> 29        Belgium 2002  206.1538     248.92704       485.8757
#> 30       Bulgaria 2002  135.3846     141.63090             NA
#> 31 Czech Republic 2002        NA            NA       146.8927
#> 32        Denmark 2002  243.0769     154.50644       242.9379
rescaleColumns(dataTest_moreYears)[c(1:5,27:32),1:5]
#>       country          time   fixedTerm fixedTermComp selfEmployment
#>  [1,] "Belgium"        "2001" "25.16"   "29.44"       "48.59"       
#>  [2,] "Bulgaria"       "2001" "16.56"   "13.85"       NA            
#>  [3,] "Czech Republic" "2001" NA        NA            "14.69"       
#>  [4,] "Denmark"        "2001" "27.07"   "15.58"       "24.29"       
#>  [5,] "Germany"        "2001" "36.62"   "4.76"        "31.07"       
#>  [6,] "Sweden"         "2001" "46.5"    "16.02"       "21.47"       
#>  [7,] "United Kingdom" "2001" "18.15"   "6.49"        "57.06"       
#>  [8,] "Belgium"        "2002" "21.34"   "24.24"       "48.59"       
#>  [9,] "Bulgaria"       "2002" "14.01"   "13.42"       NA            
#> [10,] "Czech Republic" "2002" NA        NA            "14.69"       
#> [11,] "Denmark"        "2002" "25.16"   "14.72"       "24.29"       
rescaleColumns(dataTest_moreYears, method="z-score", decim=3)[1:5,1:5]
#>      country          time   fixedTerm fixedTermComp selfEmployment
#> [1,] "Belgium"        "2001" "-0.258"  "0.373"       "0.373"       
#> [2,] "Bulgaria"       "2001" "-0.679"  "-0.388"      NA            
#> [3,] "Czech Republic" "2001" NA        NA            "-0.976"      
#> [4,] "Denmark"        "2001" "-0.164"  "-0.303"      "-0.593"      
#> [5,] "Germany"        "2001" "0.304"   "-0.831"      "-0.324"