difs {musica} | R Documentation |
Functions for evaluating distance between variables
Description
Functions for evaluating distance between variables
Usage
dif(x, y, var)
rev_dif(x, y, var)
rev_difv(x, var)
Arguments
x , y |
variables to be compared |
var |
variable code |
Value
Difference or ratio of x
and y
(for dif
) and sum or product (for rev_dif
and rev_difv
). Distance is measured as difference for variables included in getOption('additive_variables')
, i.e. temperature (TAS
) by default, and as a ratio for other variables.
While rev_dif
returns sum(x, y)
or prod(x, y)
, rev_difv
takes single vector x
and returns sum(x)
or prod(x)
.
Used mainly in other functions of the package.
Examples
getOption('additive_variables')
# calculate distance of 2 vectors
dif(c(10, 20, 30), c(11, 18, 3), 'TAS')
dif(c(10, 20, 30), c(11, 18, 3), 'PR')
# inverse for 2 vectors
rev_dif(c(10, 20, 30), c(11, 18, 3), 'TAS')
# inverse for 1 vector
rev_difv(c(10, 1.1, .9), 'TAS')
[Package musica version 0.1.3 Index]