distance {OpenRepGrid} | R Documentation |
Distance measures (between constructs or elements).
Description
Various distance measures between elements or constructs are calculated.
Usage
distance(
x,
along = 1,
dmethod = "euclidean",
p = 2,
normalize = FALSE,
trim = 20,
index = TRUE,
...
)
Arguments
x |
|
along |
Whether to calculate distance for 1 = constructs (default) or for 2= elements. |
dmethod |
The distance measure to be used. This must be one of
"euclidean", "maximum", "manhattan", "canberra", "binary"
or "minkowski". Any unambiguous substring can be given.
For additional information on the different types type
|
p |
The power of the Minkowski distance, in case |
normalize |
Use normalized distances. The distances are divided by the
highest possible value given the rating scale fo the grid,
so all distances are in the interval |
trim |
The number of characters a construct or element is trimmed to (default is
|
index |
Whether to print the number of the construct or element
in front of the name (default is |
... |
Additional parameters to be passed to function |
Value
matrix
object.
Examples
# between constructs
distance(bell2010, along = 1)
distance(bell2010, along = 1, normalize = TRUE)
# between elements
distance(bell2010, along = 2)
# several distance methods
distance(bell2010, dm = "man") # manhattan distance
distance(bell2010, dm = "mink", p = 3) # minkowski metric to the power of 3
# to save the results without printing to the console
d <- distance(bell2010, trim = 7)
d
# some more options when printing the distance matrix
print(d, digits = 5)
print(d, col.index = FALSE)
print(d, upper = FALSE)
# accessing entries from the matrix
d[1, 3]