{COINr}R Documentation

Normalise a data frame


Normalises a data frame using specifications specified in global_specs. Columns can also optionally be normalised with individual specifications using the indiv_specs argument. If variables should have their directions reversed, this can be specified using the directions argument. Non-numeric columns are ignored automatically by this function. By default, this function normalises each indicator using the "min-max" method, scaling indicators to lie between 0 and 100. This calls the n_minmax() function. COINr has a number of built-in normalisation functions of the form ⁠n_*()⁠. See online documentation for details.


## S3 method for class 'data.frame'
Normalise(x, global_specs = NULL, indiv_specs = NULL, directions = NULL, ...)



A data frame


Specifications to apply to all columns, apart from those specified by indiv_specs. See details.


Specifications applied to specific columns, overriding those specified in global_specs. See details.


An optional data frame containing the following columns:

  • iCode The indicator code, corresponding to the column names of the data frame

  • Direction numeric vector with entries either -1 or 1 If directions is not specified, the directions will all be assigned as 1. Non-numeric columns do not need to have directions assigned.


arguments passed to or from other methods.


Global specification

The global_specs argument is a list which specifies the normalisation function and any function parameters that should be used to normalise the columns of x. Unless indiv_specs is specified, this will be applied to all numeric columns of x. The list should have two entries:

In this list, f_n should be a character string which is the name of a normalisation function. For example, f_n = "n_minmax" calls the n_minmax() function. f_n_para is a list of any further arguments to f_n. This means that any function can be passed to Normalise(), as long as its first argument is x, a numeric vector, and it returns a numeric vector of the same length. See n_minmax() for an example.

f_n_para is required to be a named list. So e.g. if we define a function f1(x, arg1, arg2) then we should specify f_n = "f1", and f_n_para = list(arg1 = val1, arg2 = val2), where val1 and val2 are the values assigned to the arguments arg1 and arg2 respectively.

The default list for global_specs is: list(f_n = "n_minmax", f_n_para = list(l_u = c(0,100))).

Note, all COINr normalisation functions (passed to f_n) are of the form ⁠n_*()⁠. Type n_ in the R Studio console and press the Tab key to see a list.

Individual column specification

Optionally, columns of x can be normalised with different normalisation functions and parameters using the indiv_specs argument. This must be specified as a named list e.g. list(i1 = specs1, i2 = specs2) where i1 and i2 are column names of x to apply individual normalisation to, and specs1 and specs2 are respectively lists of the same format as global_specs (see above). In other words, indiv_specs is a big list wrapping together global_specs-style lists. Any numeric columns of x not named in indiv_specs ( i.e. those not in names(indiv_specs)) are normalised using the specifications from global_specs. So indiv_specs lists the exceptions to global_specs.

See also vignette("normalise") for more details.


A normalised data frame


iris_norm <- Normalise(iris)

[Package COINr version 1.1.14 Index]