getAlternativesComparisonsValues: Get alternatives comparisons values

Description Usage Arguments Value Examples

Description

Gets alternatives comparisons values stored in the <alternativesComparisons> tag, from an XML tree written according to the XMCDA standard.

Usage

1
getAlternativesComparisonsValues(tree, alternativesIDs, mcdaConcept = NULL)

Arguments

tree

Object containing the XMCDA XML tree.

alternativesIDs

A vector containing the IDs of the alternatives to be considered for the extractions.

mcdaConcept

A string containing the specific mcdaConcept attribute which should be searched for.

Value

The function returns a list structured as follows:

The first elements contain matrices representing each an <alternativesComparisons>. Each row c(i, j, v) of each matrix corresponds to a comparison between i-th (<initial>) and j-th (<terminal>) alternatives with value v. Elements of returned list are named according to the mcdaConcept attribute if it can be found.

status

Either OK if all the <alternativesComparisons> tags could be correctly read, or the description of the error.

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
28
29
30
31
tree = newXMLDoc()

newXMLNode("xmcda:XMCDA", 
           namespace = c("xsi" = "http://www.w3.org/2001/XMLSchema-instance", 
           "xmcda" = "http://www.decision-deck.org/2009/XMCDA-2.1.0"), 
           parent=tree)

root <- getNodeSet(tree, "/xmcda:XMCDA")
altComp <- newXMLNode("alternativesComparisons", parent=root[[1]] , namespace=c())
pairs <- newXMLNode("pairs", parent=altComp, namespace=c())


pair <- newXMLNode("pair", parent=pairs, namespace=c())
initial <- newXMLNode("initial", parent=pair)
newXMLNode("alternativeID", "a01", parent=initial, namespace=c())
terminal <- newXMLNode("terminal", parent=pair, namespace=c())
newXMLNode("alternativeID", "a02", parent=terminal, namespace=c())
value <- newXMLNode("value", parent=pair, namespace=c())
newXMLNode("real", "1", parent=value, namespace=c())

pair <- newXMLNode("pair", parent=pairs, namespace=c())
initial <- newXMLNode("initial", parent=pair)
newXMLNode("alternativeID", "a01", parent=initial, namespace=c())
terminal <- newXMLNode("terminal", parent=pair, namespace=c())
newXMLNode("alternativeID", "a03", parent=terminal, namespace=c())
value <- newXMLNode("value", parent=pair, namespace=c())
newXMLNode("real", "9", parent=value, namespace=c())

alternativesIDs <- c("a01", "a02", "a03")

x <- getAlternativesComparisonsValues(tree, alternativesIDs)

RXMCDA documentation built on May 1, 2019, 10:23 p.m.