EdgeAttributes: Edge attributes

Description Usage Arguments Details Value Note See Also Examples

Description

This function creates an aspect for additional attributes of edges.

Usage

1
2
3
4
5
6
7
8
createEdgeAttributes(
  propertyOf,
  name,
  value,
  dataType = NULL,
  isList = NULL,
  subnetworkId = NULL
)

Arguments

propertyOf

integer; reference to edge ids

name

character; key of the attribute

value

character; value of the attribute

dataType

character (optional); data type of the attribute

isList

logical (optional); a value should be considered as list

subnetworkId

integer (optional); reference to subnetwork id

Details

Edges may have additional attributes besides a name and a representation. Those additional attributes reference a edge by its id and are defined in a key-value like manner, with the name of the attribute as key. The same attribute can also be defined for different subnetworks with different values. The values itself may also differ in their data types, therefore it is necessary to provide the values as a list of the single values instead of a vector.

With isList it can be set, if a value should be considered as a list. This is of minor significance while working solely with RCX objects, unless it will be transformed to JSON. For some attributes it might be necessary that the values are encoded as lists, even if they contain only one element (or even zero elements). To force an element to be encoded correctly, this parameter can be used, for example: name="A", value=a, isList=T will be encoded in JSON as A=["a"].

Value

EdgeAttributesAspect object

Note

The propertyOf parameter references the edge ids to which the attributes belong to. When adding an EdgeAttributesAspect object to an RCX object, those ids must be present in the Edges aspect, otherwise an error is raised.

See Also

updateEdgeAttributes

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
## a minimal example
edgeAttributes = createEdgeAttributes(
  propertyOf=1, 
  name="A", 
  value="a"
)

## defining several properties at once
edgeAttributes = createEdgeAttributes(
  propertyOf=c(1,1), 
  name=c("A", "B"), 
  value=c("a","b")
)

## with characters and numbers mixed
edgeAttributes = createEdgeAttributes(
  propertyOf=c(1,1),
  name=c("A","B"),
  value=list("a",3.14)
)

## force the number to be characters
edgeAttributes = createEdgeAttributes(
  propertyOf=c(1,1),
  name=c("A","B"),
  value=list("a",3.14),
  dataType=c("character","character")
)

## with a list as input for one value
edgeAttributes = createEdgeAttributes(
  propertyOf=c(1,1),
  name=c("A","B"),
  value=list(c("a1","a2"),
             "b")
)

## force "B" to be a list as well
edgeAttributes = createEdgeAttributes(
  propertyOf=c(1,1),
  name=c("A","B"),
  value=list(c("a1","a2"),
             "b"),
  isList=c(TRUE,TRUE)
)

## with a subnetwork
edgeAttributes = createEdgeAttributes(
  propertyOf=c(1,1),
  name=c("A","A"),
  value=c("a","a with subnetwork"),
  subnetworkId=c(NA,1)
)

## with all parameters
edgeAttributes = createEdgeAttributes(
  propertyOf=c(1,1,1,1),
  name=c("A","A","B","B"),
  value=list(c("a1","a2"),
             "a with subnetwork",
             "b",
             "b with subnetwork"),
  isList=c(TRUE,FALSE,TRUE,FALSE),
  subnetworkId=c(NA,1,NA,1)
)

frankkramer-lab/RCX documentation built on Oct. 26, 2021, 1:33 a.m.