Learn R Programming

OpenRepGrid (version 0.1.9)

distance: 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, trim = 20, index = TRUE, ...)

Arguments

x
repgrid object.
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 ?dist.
p
The power of the Minkowski distance, in case "minkowski" is used as argument for dmethod.
trim
The number of characters a construct or element is trimmed to (default is 20). If NA no trimming occurs. Trimming simply saves space when displaying correlation of constructs with long names.
index
Whether to print the number of the construct or element in front of the name (default is TRUE). This is useful to avoid identical row names, which may cause an error.
...
Additional parameters to be passed to function dist. Type dist for further information.

Value

matrix object.

Examples

Run this code
## Not run: 
# 
#    # between constructs
#    distance(bell2010, along=1)
#    # 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]
# 
# ## End(Not run)

Run the code above in your browser using DataLab