Learn R Programming

networkDynamic (version 0.11.5)

adjust.activity: Adjust the activity ranges in all of the spells of a networkDynamic object

Description

Transforms the values of all the activity spells of vertices and edges, as well as spells of dynamic TEA attributes (and the net.obs.period if it exists).

Usage

adjust.activity(nd, offset = 0, factor = 1)

Value

The nd argument is modified in place and returned invisibly.

Arguments

nd

networkDynamic object to be modified

offset

numeric value to be added (or subtracted) to all spell values

factor

numeric factor for multiplying all spell values

Author

skyebend@uw.edu

Details

Spell values are modified by first adding the value of offset and then multiplying by factor. If a net.obs.period attribute exists, it's observation spell values are transformed, and the time.increment value is multiplied by factor.

See Also

See also activity.attribute, attribute.activity.functions and net.obs.period

Examples

Run this code
# convert steps of an imaginary discrete sim
# with each steps corresponding to 1 day
# into decimal 'years' since 1990
sim<-network.initialize(5)
activate.vertices(sim,onset=0,terminus=2546)
add.edges.active(sim,head=1:4,tail=2:5,onset=0,terminus=2546)
set.network.attribute(sim,'net.obs.period',list(
   observations=list(c(0,2546)),mode="discrete", 
   time.increment=1,time.unit="step"))

# do the transformation
adjust.activity(sim,offset=1990*365.25,factor=1/365.25)

# modify the 'units' of net.obs.period
obs <-get.network.attribute(sim,'net.obs.period')
obs$time.unit<-'year'
set.network.attribute(sim,'net.obs.period',obs)

# peek at the new values
as.data.frame(sim)
get.network.attribute(sim,'net.obs.period')

Run the code above in your browser using DataLab