knitr::opts_chunk$set(collapse = TRUE, comment = "#")
library(OpenRepGrid)
options(width=120)
settings(show.scale=FALSE, show.meta=FALSE)

Description

Distances between elements are used as a measure of similarity. For elements, distance measure have the advantage that they are not affected by construct reflection as it is the case for correlations between elements (see elementCor). The following distance measures are available:

For most grid purposes, the first two options will suffice.

R-Code

In OpenRepGrid the function distance calculates various types of distances for constructs and for elements (the default is euclidean). The argument along determines if distances for 1) constructs or 2) elements are calculated. The default is to calculate distances for constructs, so we always need to set along=2 to prompt element distances.

distance(fbb2003, along=2)          # along = 2 for elements

To change the distance measure supply any unambigous string of the available distance methods to the argument dmethod. E.g. for the manhattan distance bewteen constructs:

distance(fbb2003, along=2, dmethod="man")

For other distance metrics:

distance(fbb2003, along=2, dm="canb")            # canberra distance for constructs
distance(fbb2003, along=2, dm="mink", p=3)       # minkowski metric to the power of 3  for constructs

If the distances are calculated for further processing, the printing to the console can be surpressed distance and the results can be saved into an object (here d).

d <- distance(fbb2003)

The object is a matrix. So we can look at the distances for the first element by

d[1, ]


markheckmann/OpenRepGrid documentation built on April 14, 2024, 8:15 a.m.