elementLookup {socialranking}R Documentation

Element lookup

Description

List coalitions that an element appears in.

Usage

elementLookup(powerRelation, element)

Arguments

powerRelation

A PowerRelation object created by PowerRelation() or as.PowerRelation()

element

an element in powerRelation$elements

Details

This function calls powerRelation$elementLookup(element). The returned list contains tuples containing the index to find the corresponding coalitions in powerRelation$eqs.

If elementLookup(powerRelation, 2) returns list(c(1,1), c(1,2), c(3,1)), we can determine that the element 2 appears twice in equivalence class 1 and once in equivalence class 3. The specific coalition then can be accessed with powerRelation$eqs[[i]][[j]], where i is the equivalence class index and j is the coalition in that equivalence class containing the element.

Value

List of tuples, each of size 2. First value of a tuple indicates the equivalence class index, the second value the index inside that equivalence class with the coalition containing the element. Returns NULL if the element does not exist.

See Also

Other lookup functions: coalitionsAreIndifferent(), equivalenceClassIndex()

Examples

pr <- as.PowerRelation("12 > 2 ~ 1")

l <- elementLookup(pr, 1)
l
# (1,1), (2,2)

sapply(l, function(tuple) 1 %in% pr$eqs[[tuple[1]]][[tuple[2]]]) |> all() |> stopifnot()

# if element does not exist, it returns NULL
elementLookup(pr, 3) |> is.null() |> stopifnot()


[Package socialranking version 1.2.0 Index]