when.attrs.match: return the times at which the TEA attributes of elements of a...

when.vertex.attrs.matchR Documentation

return the times at which the TEA attributes of elements of a network match a value

Description

The functions query the TEA attributes of network elements (vertices or edges) and return the time that each element matches the specified value. The match operator defaults to '==', but other binary comparison operators that return logical, such as '>' or even '%in%' can be used as well.

Usage

when.vertex.attrs.match(nd, attrname, value, match.op = "==", rule = "earliest", 
                        no.match = Inf, v = seq_len(network.size(nd)))
                        
when.edge.attrs.match(nd, attrname, value, match.op = "==", rule = "earliest", 
                        no.match = Inf, e = seq_along(nd$mel))                        

Arguments

nd

a networkDynamic object

attrname

character name of the TEA attribute to be queried

value

the value to be passed to the comparison operator to be matched against the TEA values

match.op

the binary operator to be used in determining a match (defaults to '==')

rule

character giving the name of the rule to determine what value should be returned from the spell of matching attributes. Options are 'earliest' (the default) and 'latest' which will return the onset and terminus of the spell respectively.

no.match

The value to be returned when the TEA attribute never matches value. Default is Inf, NA may be useful as well.

v

possible numeric vector of vertex ids indicating a subset of vertices to be queried

e

possible numeric vector of edge ids indicating a subset of edges to be queried

Details

The no.match argument is included to make it possible for user to distinguish cases where the attribute is missing from the network element (which will return NA) from cases where the value of the attribute never matches value according to the operation match.op

Value

A numeric vector of attribute onset times (if rule='earliest') or termination times (if rule='latest')

Note

this is a draft implementation, suggestions on function and argument names welcome.

Author(s)

skyebend

See Also

See also attribute.activity.functions

Examples


# create a network with TEA attribute
net<-network.initialize(5)
net<-activate.vertex.attribute(net,'test','A',onset=0,terminus=2)
net<-activate.vertex.attribute(net,'test','B',onset=2,terminus=3)
net<-activate.vertex.attribute(net,'test','C',onset=4,terminus=5)

net<-activate.vertex.attribute(net,'weight',0,onset=-Inf,terminus=Inf)
net<-activate.vertex.attribute(net,'weight',-1,at=6,v=2)

# when does 'test' take the value 'B' for each vertex?
when.vertex.attrs.match(net,'test',value='B')

# when is the terminus of when 'test' takes a value 'A' or 'C'?
when.vertex.attrs.match(net,'test',value=c('A','C'),match.op='%in%',rule='latest')

# when does 'weight' first take a value less than 0?
when.vertex.attrs.match(net,'weight',value=0,match.op='<')


networkDynamic documentation built on May 29, 2024, 1:16 a.m.