Normalise.numeric {COINr} | R Documentation |
Normalise a numeric vector
Description
Normalise a numeric vector using a specified function f_n
, with possible reversal of direction
using direction
.
Usage
## S3 method for class 'numeric'
Normalise(x, f_n = NULL, f_n_para = NULL, direction = 1, ...)
Arguments
x |
Object to be normalised |
f_n |
The normalisation method, specified as string which refers to a function of the form |
f_n_para |
Supporting list of arguments for |
direction |
If |
... |
arguments passed to or from other methods. |
Details
Normalisation is specified using the f_n
and f_n_para
arguments. In these, 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.
COINr has a number of built-in normalisation functions of the form n_*()
. See online documentation
for details.
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.
See also vignette("normalise")
for more details.
Value
A normalised numeric vector
Examples
# example vector
x <- runif(10)
# normalise using distance to reference (5th data point)
x_norm <- Normalise(x, f_n = "n_dist2ref", f_n_para = list(iref = 5))
# view side by side
data.frame(x, x_norm)