distance: Distance measures (between constructs or elements).

Description Usage Arguments Value Author(s) Examples

View source: R/distance.R

Description

Various distance measures between elements or constructs are calculated.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
distance(
  x,
  along = 1,
  dmethod = "euclidean",
  p = 2,
  normalize = FALSE,
  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.

normalize

Use normalized distances. The distances are divided by the highest possible value given the rating sclae fo the grid, so all distances are in the interval [0,1].

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.

Author(s)

Mark Heckmann

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Not run: 

   # 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]


## End(Not run)

markheckmann/OpenRepGrid documentation built on April 30, 2021, 2:33 a.m.