Learn R Programming

RQDA (version 0.1-6)

relation: Relation between two codings

Description

To calculate the relation between two codings, given the coding indexes.

Usage

relation(index1, index2)

Arguments

index1
The first coding index, it is length-2 integer vector with the first element (index1[1]) less than the second element (index1[2]).
index2
The second coding index, it is length-2 integer vector with the first element (index2[1]) less than the second element (index2[2]).

Value

  • A 6-element list:
  • RelationLength-1 character, standing for the type of relation. It may be one of inclusion, overlap, exact or proximity.
  • OverlapIndexLength-2 vector, the index of overlapping between two coding indexes. It is c(NA,NA) when relation is proximity.
  • UnionIndexLength-2 vector, the index of union of the two coding indexes. It is c(NA,NA) when relation is proximity.
  • DistanceDistance of two coding indexes. It is NA when relation is not proximity.
  • WhichMinWhich argument (index1 or index2) has the minimum value. If both have the same minmum value, return NA.
  • WhichMaxWhich argument (index1 or index2) has the maximum value. If both have the same maxmum value, return NA.

Details

The relation between two codings can be any of inclusion, overlap, exact (special case of inclusion and overlap) and proximity (Neither overlap nor inclusion).

Examples

Run this code
relation(c(20,30),c(22,28)) # inclusion
relation(c(10,40),c(20,80)) # overlap
relation(c(10,20),c(30,50)) # proximity with distance of 10
relation(c(10,20),c(10,20)) # exact
relation(c(10,20),c(10,30)) # WhichMin is c(1,2)

Run the code above in your browser using DataLab